1.0.0 • Published 7 years ago

react-native-password-guard-input v1.0.0

Weekly downloads
89
License
ISC
Repository
github
Last release
7 years ago

react-native-password-guard-input

密码卫士

Install 安装

npm i react-native-password-guard-input --S
react-native link react-native-password-guard-input

Configuration 配置

android

在项目的android/app/src/AndroidManifest.xml文件中加入:

<meta-data android:name="PGI_LICENSE" android:value="${PGI_LICENSE}" />
<meta-data android:name="PGI_CIPHER_KEY" android:value="${PGI_CIPHER_KEY}" />
<meta-data android:name="PGI_PUBLIC_KEY" android:value="${PGI_PUBLIC_KEY}" />
<meta-data android:name="PGI_ECC_KEY" android:value="${PGI_ECC_KEY}" />

在项目的android/app/build.gradle文件的defaultConfig节点内增加:

 manifestPlaceholders = [
       PGI_LICENSE   : [YOUR-LICENSE],
       PGI_CIPHER_KEY: [YOUR-CIPHER_KEY],
       PGI_PUBLIC_KEY: [YOUR-PUBLIC_KEY],
       PGI_ECC_KEY   : [YOUR-ECC_KEY],
  ]

Props属性

NameTypeDefaultNote
isNumberPadboolfalse是否显示为数字键盘
isEncryptbooltrue是否对输入的文字进行加密
hasPressAnimboolfalse是否有按键的动画效果
hasPressStateboolfalse是否有按键的按下状态
maxLengthnumber100最大输入长度
reorderTypenumber0键盘是否乱序;可选值:0:默认不乱序;1:初始化后只乱序一次;2:每次点击键盘都重新排序。
inputRegexstring键盘输入正则规则,默认为无限制。
onTextChangedfunc输入框内文本发生变化的回调;返回的值为object。具体见下面;

onTextChanged 事件的返回值枚举

NameTypeDefaultNote
textLengthnumber0用户输入数据的长度
aesCipherTextstringnullAES加密密文,Base64编码
md5CipherTextstringnullMD5哈希值
rsaAesCipherTextstringnullRSA+AES加密密文,Base64编码
sm2CipherTextstringnullSM2加密密文,Base64编码
sm3CipherTextstringnullSM3加密密文,十六进制编码
sm4CipherTextstringnullSM4加密密文,Base64编码

Usage 使用

.....
import PassGuardInput from 'react-native-password-guard-input';

export default class PasswordInputExample extends Component {
    render() {
        return (
            <View style={styles.container}>
            	<PassGuardInput hasPressState={true} isNumberPad={true} 
            		maxLength={6}  onTextChanged={this._onChange.bind(this)}
            		style={{ width: 100, height: 40 }}/>
            </View>
        );
    }

    _onChange(t) {
        console.log(t);
    }
}
.....