Skip to content

Instantly share code, notes, and snippets.

@akaita
akaita / encryptedsharedpreferences-12.kt
Last active Jan 28, 2020
encryptedsharedpreferences-12.kt
View encryptedsharedpreferences-12.kt
// Step 1: Create or retrieve the Master Key for encryption/decryption
val masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
// Step 2: Initialize/open an instance of EncryptedSharedPreferences
val sharedPreferences = EncryptedSharedPreferences.create(
"PreferencesFilename",
masterKeyAlias,
applicationContext,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
View page_withjs.cfm
<cfimport prefix="divvy" taglib="/customTags">
...
...
<!--- <script src="/js/myscript.js"></script> --->
<akaita:js_script src="/js/myscript.js"></akaita:js_script>
...
@akaita
akaita / js_script.cfm
Created Nov 19, 2019
Custom tag for ColdFusion implementing cache busting
View js_script.cfm
<!---
Goal: implement timestamp-based cache busting
For example: instead of loading a javascript file from "http://www.example.com/myscript.js", it'll load it from "http://www.example.com/myscript.js?20191101160030"
Usage examples:
- add as global tag and: <CF_js_script src="/js/myscript.js">
- <cfimport prefix="akaita" taglib="customTags"> and then <akaita:js_script src="/js/myscript.js"></akaita:js_script>
--->
<CFSETTING ENABLECFOUTPUTONLY="Yes">
@akaita
akaita / encryptedsharedpreferences-4.kt
Last active Oct 13, 2019
encryptedsharedpreferences-4.kt
View encryptedsharedpreferences-4.kt
// Step 3: Read data from EncryptedSharedPreferences as usual
val value = sharedPreferences.getString("DATA", "")
@akaita
akaita / encryptedsharedpreferences-cleartext.xml
Created Oct 13, 2019
encryptedsharedpreferences-cleartext.xml
View encryptedsharedpreferences-cleartext.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="DATA">akaita</string>
</map>
@akaita
akaita / encryptedsharedpreferences-encrypted.xml
Created Oct 13, 2019
encryptedsharedpreferences-encrypted.xml
View encryptedsharedpreferences-encrypted.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="AVz2qCVxm1KudCCJKYuxuoaAXoPeWKjG0w==">ASnO9uni11t3m9sNgDJbiYllL/tE+i99TYKfQ0h8XV6AUN0O3rBxBsMmcpw2DCY=</string>
<string name="__androidx_security_crypto_encrypted_prefs_key_keyset__">12a901eb372af4775b09f5b51d20d49428931c5d8e0b17dd103d2169c1879b8b13958274d7e25d3cc052f301461495fd40b70806ae244f456726802460318bdf19dce444e7a60f20c903c5a57140ea8e90a19a1b48559961d145a50000d1c0e22ca918b02ea0cc34e433900f44c00e9c791ecb678f26d293c0226d6c2a9e25e610616ec34241b06410481427a850eeedf85ee4c725d5dbd715b5a8d0e017be9a568a9f960989271d14d2d0531a4408a5d0dae705123c0a30747970652e676f6f676c65617069732e636f6d2f676f6f676c652e63727970746f2e74696e6b2e4165735369764b6579100118a5d0dae7052001</string>
<string name="__androidx_security_crypto_encrypted_prefs_value_keyset__">12880189e734bbbf9cfa3bc15b5e53ea8df03341269cf97112a60a1f6482732dd33248b3f821397fb04ef3372ff54336e9045a0b0c0fb7afdf475dbc98a1107d09de66afcc5ad063e5e5b59a7d616e14834e19769bc84de7e5c8716a8
@akaita
akaita / encryptedsharedpreferences-3.kt
Created Oct 12, 2019
encryptedsharedpreferences-3.kt
View encryptedsharedpreferences-3.kt
// Step 3: Save data to the EncryptedSharedPreferences as usual
sharedPreferences.edit()
.putString("DATA", saveText.text.toString())
.apply()
@akaita
akaita / encryptedsharedpreferences-build2.gradle
Created Oct 12, 2019
encryptedsharedpreferences-build2.gradle
View encryptedsharedpreferences-build2.gradle
implementation "androidx.security:security-crypto:1.0.0-alpha02"
View unmaintainable-code-30.java
#define ONE 1
#define TWO 2
#define THREE 3
#define FOUR 4
#define FIVE 4
#define SIX 6
#define SEVEN 7
#define EIGHT 8
#define NINE 9
...