PU - Public Key
PK - Private Key
SK - Secret Key
SID - Session ID
P - Payload
This file contains 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 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 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 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 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 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 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 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 |
This file contains 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 2 arguments: ENCRYPTED, KEY. But actual is $#!"; exit 1; fi | |
ENCRYPTED="$1" | |
KEY="$2" | |
for it in ENCRYPTED KEY; do | |
if test -z "${!it}"; then echo "Argument \"$it\" is empty!"; exit 1; fi; done |
NewerOlder