PU - Public Key
PK - Private Key
SK - Secret Key
SID - Session ID
P - Payload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # key | |
| openssl rand -hex 32 | |
| # iv | |
| openssl rand -hex 16 | |
| openssl enc -aes-256-cbc -P | |
| # salt=C0FDB84CFB4ED88F | |
| # key=1D5659F237383B18E22169C06C88DD452C61285D2D154ECCBE781A187DE5521D | |
| # iv =A85A73961775FEC214ECC7155B139D70 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/bash | |
| if test $# -ne 2; then | |
| echo "Script needs for 2 arguments but actual $#!"; exit 12; fi | |
| SRC="$1" | |
| DST="$2" | |
| if [[ ! -d "$SRC" ]]; then echo "SRC: $SRC is not a dir!"; exit 1; fi | |
| if [[ ! -d "$DST" ]]; then echo "DST: $DST is not a dir!"; exit 1; fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun toInt(b1: Byte, b2: Byte, b3: Byte, b4: Byte): Int { | |
| return b1.toInt().and(0xff).shl(8 * 3) | |
| .or(b2.toInt().and(0xff).shl(8 * 2)) | |
| .or(b3.toInt().and(0xff).shl(8 * 1)) | |
| .or(b4.toInt().and(0xff)) | |
| } | |
| // 0 1 2 3 | |
| // 01234567 01234567 01234567 01234567 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/bash | |
| # d=256 | |
| d=512 | |
| g="$(((RANDOM % d) + 1))" | |
| p="$(((RANDOM % d) + 1))" | |
| echo '' | |
| echo 'public:' | |
| echo "g = $g" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/local/bin/bash | |
| echo 'Enter service name (default is common):' | |
| read SERVICE_NAME || exit 1 | |
| if test -z "$SERVICE_NAME"; then | |
| SERVICE_NAME='common'; fi | |
| echo 'Enter account name:' | |
| read ACCOUNT_NAME || exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| KEYCHAIN='keychain_baz' | |
| # https://www.unix.com/man-page/osx/1/security/ | |
| security delete-keychain "$KEYCHAIN" | |
| security create-keychain -P "$KEYCHAIN" | |
| if test $? -ne 0; then | |
| echo 'Create keychain error!'; exit 1; fi | |
| SERVICE_NAME='service_foo' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SERVICE_NAME='service_foo' | |
| ACCOUNT_NAME='account_bar' | |
| PASSWORD_VALUE='password_bar' | |
| security delete-generic-password -s "$SERVICE_NAME" -a "$ACCOUNT_NAME" &> /dev/null | |
| # Add a generic password item to the default keychain. | |
| security add-generic-password -s "$SERVICE_NAME" -a "$ACCOUNT_NAME" -w "$PASSWORD_VALUE" -T '' | |
| if test $? -ne 0; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SERVICE_NAME='service_foo' | |
| ACCOUNT_NAME='account_bar' | |
| PASSWORD_VALUE='password_bar' | |
| security delete-generic-password -s "$SERVICE_NAME" -a "$ACCOUNT_NAME" &> /dev/null | |
| # Add a generic password item to the default keychain without warning. | |
| security add-generic-password -s "$SERVICE_NAME" -a "$ACCOUNT_NAME" -w "$PASSWORD_VALUE" | |
| if test $? -ne 0; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sealed interface ExtraType<T : Any> | |
| object Str : ExtraType<String> | |
| object Int32 : ExtraType<Int> | |
| object Int64 : ExtraType<Long> | |
| private fun <T : Any> Bundle.getOrNull(type: ExtraType<T>, key: String): T? { | |
| if (!containsKey(key)) return null | |
| return when (type) { | |
| Str -> getString(key, null) as T? | |
| Int64 -> getLong(key, -1) as T |
NewerOlder