Skip to content

Instantly share code, notes, and snippets.

Avatar

Yakiv Mospan yakivmospan

View GitHub Profile
View DynamicTexturesSmaple.kt
val fakeObject = ModelRenderable.builder()
.setSource(context, R.raw.fakeObject)
.build()
val defaultMaterial = fakeObject.get().material
val realObject = ModelRenderable.builder()
.setSource(context, URI("object_name"))
.build()
val realObjectMaterial = defaultMaterial.copy()apply{
setTexture("baseColorMap", diffuse)
setTexture("metallicMap", metallic)
View pbr_material.mat
material {
name : "Textured material",
parameters : [
{
type : sampler2d,
name : baseColorMap
},
{
type : sampler2d,
name : normalMap
View SystemServices.kt
val message = "Very large message, bigger then 250 symblos..."
// Simple Shared Preferences wrapper, will be used to save wrapped key
val storage = Storage(context)
// Creates Android Key Store and provides manage functions
val keyStoreWrapper = KeyStoreWrapper(context)
// Create and Save asymmetric key
keyStoreWrapper.createAndroidKeyStoreSymmetricKey("MASTER_KEY")
@yakivmospan
yakivmospan / pr.md
Created Feb 4, 2018 — forked from piscisaureus/pr.md
Checkout github pull requests locally
View pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

View CipherWrapper.kt
fun decrypt(data: String, key: Key?, useInitializationVector: Boolean = false): String {
var encodedString: String
if (useInitializationVector) {
val split = data.split(IV_SEPARATOR.toRegex())
if (split.size != 2) throw IllegalArgumentException("Passed data is incorrect. There was no IV specified with it.")
val ivString = split[0]
encodedString = split[1]
val ivSpec = IvParameterSpec(Base64.decode(ivString, Base64.DEFAULT))
View CipherWrapper.kt
fun encrypt(data: String, key: Key?, useInitializationVector: Boolean = false): String {
cipher.init(Cipher.ENCRYPT_MODE, key)
var result = ""
if (useInitializationVector) {
val iv = cipher.iv
val ivString = Base64.encodeToString(iv, Base64.DEFAULT)
result = ivString + IV_SEPARATOR
}
val bytes = cipher.doFinal(data.toByteArray())
View SystemServices.kt
// Creates Cipher with asymmetric transformation and provides wrap and unwrap functions
val cipherForWrapping = CipherWrapper("RSA/ECB/PKCS1Padding")
// Creates Cipher with symmetric transformation and provides encrypt and decrypt functions
val cipherForEncryption = CipherWrapper("AES/CBC/PKCS7Padding")
// ---------------- Create Keys
// Create AES BC provider key
val symmetricKey = keyStoreWrapper.generateDefaultSymmetricKey()
View SystemServices.kt
// Create and Save asymmetric key
keyStoreWrapper.createAndroidKeyStoreSymmetricKey("MASTER_KEY")
// Get key from keyStore
val masterKey = keyStoreWrapper.getAndroidKeyStoreSymmetricKey("MASTER_KEY")
// Creates Cipher with symmetric transformation and provides encrypt and decrypt functions
val cipher = CipherWrapper("AES/CBC/PKCS7Padding")
// Encrypt message
View SystemServices.kt
val message = "Very large message, bigger then 250 symblos..."
// Simple Shared Preferences wrapper, will be used to save wrapped key
val storage = Storage(context)
// Creates Android Key Store and provides manage functions
val keyStoreWrapper = KeyStoreWrapper(context)
View KeySize.kt
// On Marshmallow and higher (API 23+)
val builder = KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
builder.setKeySize(1024)
// On Kitkat and up to Marshmallow (API 19 - 22)
val builder = KeyPairGeneratorSpec.Builder(context)
builder.setKeySize(1024)