首页
工具
隐私协议
App Privacy Policy
更多
作品
关于我们
Search
1
android5遇到INSTALL_FAILED_DEXOPT 解决办法
1,664 阅读
2
设置max_connections无效
1,484 阅读
3
FlexboxLayout+recyclerView实现自动换行
1,375 阅读
4
Nginx配置多个域名
1,257 阅读
5
Android P http网络请求失败
1,230 阅读
默认分类
mysql
android
android深入
Jetpack Compose
Android传感器
php
Yii2
windows
webrtc
登录
Search
标签搜索
android
kotlin
webrtc
kurento
mysql
adb
nginx
flutter
rsa
微信
git
Yii2
md5
加密
dart
aes
wechat
windows
小程序
dexopt
Typecho
累计撰写
80
篇文章
累计收到
3
条评论
首页
栏目
默认分类
mysql
android
android深入
Jetpack Compose
Android传感器
php
Yii2
windows
webrtc
页面
工具
隐私协议
App Privacy Policy
作品
关于我们
搜索到
75
篇与
默认分类
的结果
2020-08-24
WIFI连接adb connect : Connection refused
adb connect 192.168.0.101出现错误failed to connect to '192.168.0.101:5555': Connection refused解决办法: 1. 手机用usb线连上电脑 2. adb tcpip 5555 3. adb connect 192.168.0.101connected to 192.168.0.104:5555连接成功
2020年08月24日
547 阅读
0 评论
0 点赞
2020-08-20
Kotlin使用注解实现Parcelable
在gradle中添加android { ... androidExtensions { experimental = true } }添加注解Parcelize并实现Parcelable接口@Parcelize data class User(val name: String, val age: Int) : Parcelable
2020年08月20日
489 阅读
0 评论
0 点赞
2020-08-17
Android加密算法之AES
什么是高级加密标准或AES?AES加密标准又称为高级加密标准Rijndael加密法,是美国国家标准技术研究所NIST旨在取代DES的21世纪的加密标准。AES加密如何工作?AES是一种对称的加密算法,可基于相同的密钥进行加密和解密。AES包含三个分组密码:AES-128,AES-192和AES-256。每个密码分别使用128 位,192位和256位的加密密钥对128 位块中的数据进行加密和解密。代码:object AESCrypt { private const val AES_MODE = "AES/CBC/PKCS7Padding" //"算法/模式/补码方式" private const val CHARSET = "UTF-8" private const val CIPHER = "AES" private const val HASH_ALGORITHM = "SHA-256" private val IV_BYTES = byteArrayOf(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) /** * Generates SHA256 hash of the password which is used as key * * @param password used to generated key * @return SHA256 of the password */ @Throws(NoSuchAlgorithmException::class, UnsupportedEncodingException::class) private fun generateKey(password: String): SecretKeySpec { val digest = MessageDigest.getInstance(HASH_ALGORITHM) val bytes = password.toByteArray(charset(CHARSET)) digest.update(bytes, 0, bytes.size) val key = digest.digest() return SecretKeySpec(key, CIPHER) } /** * Encrypt and encode message using 256-bit AES with key generated from password. * * @param password used to generated key * @param message the thing you want to encrypt assumed String UTF-8 * @return Base64 encoded CipherText * @throws GeneralSecurityException if problems occur during encryption */ @Throws(GeneralSecurityException::class) fun encrypt(password: String, message: String): String { try { val key = generateKey(password) val cipherText = encrypt(key, IV_BYTES, message.toByteArray(charset(CHARSET))) //NO_WRAP is important as was getting \n at the end return Base64.encodeToString(cipherText, Base64.NO_WRAP) } catch (e: UnsupportedEncodingException) { throw GeneralSecurityException(e) } } /** * More flexible AES encrypt that doesn't encode * * @param key AES key typically 128, 192 or 256 bit * @param iv Initiation Vector * @param message in bytes (assumed it's already been decoded) * @return Encrypted cipher text (not encoded) * @throws GeneralSecurityException if something goes wrong during encryption */ @Throws(GeneralSecurityException::class) fun encrypt(key: SecretKeySpec, iv: ByteArray, message: ByteArray): ByteArray { val cipher = Cipher.getInstance(AES_MODE) val ivSpec = IvParameterSpec(iv) cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec) return cipher.doFinal(message) } /** * Decrypt and decode ciphertext using 256-bit AES with key generated from password * * @param password used to generated key * @param base64EncodedCipherText the encrpyted message encoded with base64 * @return message in Plain text (String UTF-8) * @throws GeneralSecurityException if there's an issue decrypting */ @Throws(GeneralSecurityException::class) fun decrypt(password: String, base64EncodedCipherText: String): String { try { val key = generateKey(password) val decodedCipherText = Base64.decode(base64EncodedCipherText, Base64.NO_WRAP) val decryptedBytes = decrypt(key, IV_BYTES, decodedCipherText) return String(decryptedBytes, charset(CHARSET)) } catch (e: UnsupportedEncodingException) { throw GeneralSecurityException(e) } } /** * More flexible AES decrypt that doesn't encode * * @param key AES key typically 128, 192 or 256 bit * @param iv Initiation Vector * @param decodedCipherText in bytes (assumed it's already been decoded) * @return Decrypted message cipher text (not encoded) * @throws GeneralSecurityException if something goes wrong during encryption */ @Throws(GeneralSecurityException::class) fun decrypt(key: SecretKeySpec, iv: ByteArray, decodedCipherText: ByteArray): ByteArray { val cipher = Cipher.getInstance(AES_MODE) val ivSpec = IvParameterSpec(iv) cipher.init(Cipher.DECRYPT_MODE, key, ivSpec) return cipher.doFinal(decodedCipherText) } }添加扩展方法,方便调用private const val key: String = "Your AES Key" fun encrypt(input: String): String { return AESCrypt.encrypt(key, input) } fun decrypt(input: String): String { return AESCrypt.decrypt(key, input) } fun String.aesEncrypt(): String = encrypt(this) fun String.aesDecrypt(): String = decrypt(this)使用方法"明文".aesEncrypt() "密文".aesDecrypt()
2020年08月17日
349 阅读
0 评论
0 点赞
2020-08-14
解决NestedScrollView嵌套RecyclerView滚动监听问题
不使用recyclerview的监听,直接用NestedScrollView的监听scrollView.setOnScrollChangeListener( NestedScrollView.OnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -> if (scrollY > oldScrollY) { Log.i(TAG, "Scroll DOWN") } if (scrollY < oldScrollY) { Log.i(TAG, "Scroll UP") } if (scrollY == 0) { Log.i(TAG, "TOP SCROLL") } if (scrollY == v.getChildAt(0).measuredHeight - v.measuredHeight) { Log.i(TAG, "BOTTOM SCROLL") } })
2020年08月14日
528 阅读
0 评论
0 点赞
2020-08-14
android加密算法之MD5
方法1fun getMD5A(str: String): String? { return try { val md: MessageDigest = MessageDigest.getInstance("MD5")//生成一个MD5加密计算摘要 md.update(str.toByteArray()) //计算md5函数 var md5Str: String = BigInteger(1, md.digest()).toString(16) if (md5Str.length < 32) { md5Str = "0$md5Str" } md5Str } catch (e: Exception) { throw Exception("MD5加密出现错误") } }方法2,修改hexDigits可生所不同的字符串:例如:charArrayOf('5','2','0','1','3','1','4','7','8','9','a','b','c','d','e','f')fun getMD5B(str: String): String? { val hexDigits = charArrayOf('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f') return try { val mdInst = MessageDigest.getInstance("MD5") mdInst.update(str.toByteArray()) val md = mdInst.digest() val j = md.size val str = CharArray(j * 2) var k = 0 for (i in 0 until j) { val byte0 = md[i] str[k++] = hexDigits[byte0.toInt().ushr(4) and 0xf] str[k++] = hexDigits[byte0.toInt().and(0xf)] } String(str) } catch (e: java.lang.Exception) { e.printStackTrace() null } }
2020年08月14日
320 阅读
0 评论
0 点赞
2020-08-13
Yii2中$model->load(Yii::$app->request->get())一直返回false
使用$model->load()方法时一直返回false,网上找许久,有说是安全问题的,加个参数就可以了,于是:$model->load(Yii::$app->request->get(),true)可还是没有解决,看代码:public function load($data, $formName = null) { $scope = $formName === null ? $this->formName() : $formName; if ($scope === '' && !empty($data)) { $this->setAttributes($data); return true; } elseif (isset($data[$scope])) { $this->setAttributes($data[$scope]); return true; } return false; }load()方法有两个参数,第一个参数 $data 是要填充的数据,第二个参数 $formName 是选择指定的模型。如果第二个参数不传,$formName 会默认为null,默认取当前模型 $this->formName()。如果指定了模型,会将模型名称作为key值,通过 $data[$formName] 取值,也就是这时候应该传的 $data 格式是:$data = [ 'User' => [ 'name' => 'test', 'phone' => '13000000000', 'email' => '
[email protected]
' ] ];如果 $formName 传空字符串,则 $data 传递参数格式为:$data = [ 'name' => 'test', 'phone' => '13000000000', 'email' => '
[email protected]
' ];这时应该用:$model->load($data, '');还有一种解决办法:$model->attributes = $data; // 或者 $model->setAttributes($data);
2020年08月13日
274 阅读
0 评论
0 点赞
2020-08-12
proguard-rules出现unresolved class name
最近将Android studio升级到4.0后,proguard-rules.pro文件出现许多错误,unresolved class name目前的解决办法是在开头加上#noinspection ShrinkerUnresolvedReference
2020年08月12日
1,180 阅读
0 评论
1 点赞
2020-08-06
getResources().getColor() is deprecated
getResources().getColor(android.R.color.white)过时了以下方法替换getResources().getColor(android.R.color.white, getActivity().getTheme()));或ContextCompat.getColor(context, R.color.color_name)
2020年08月06日
378 阅读
0 评论
0 点赞
2020-08-01
git clone时出现 Failed to connect to 127.0.0.1 port 1080: Connection refused
查询是否使用代理git config --global http.proxy取消代理git config --global --unset http.proxy
2020年08月01日
478 阅读
0 评论
0 点赞
2020-08-01
ubuntu不能启动,进入initramfs
最近升级了下自己的电脑,开机就进入了initramfs了解决方法在initramfs中输入reboot重启,然后在高级模式中选择recover modeThe root filesystem on /dev/sda2 requires a manual fsck根据提示出错的盘符输入指令修复fsck -t ext4 /dev/sda2后面一路输入y完成后reboot重启即可
2020年08月01日
230 阅读
0 评论
0 点赞
1
...
5
6
7
8