Skip to content

Instantly share code, notes, and snippets.

Arpit Jain calvincodes

Block or report user

Report or block calvincodes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@calvincodes
calvincodes / jwt_creation_4_to_5.scala
Created Aug 14, 2019
Describes Step 4 to 5 of JWT creation
View jwt_creation_4_to_5.scala
val hash = hash_alg(data, secret_key) // Step 4
val signature = base64UrlEncode(hash) // Step 5
@calvincodes
calvincodes / jwt_creation_1_to_3.scala
Created Aug 14, 2019
Describes Step 1 to 3 of JWT creation
View jwt_creation_1_to_3.scala
val header = base64UrlEncode(header_json) // Step 1
val payload = base64UrlEncode(payload_json) // Step 2
val data = header + "." + payload // Step 3
@calvincodes
calvincodes / jwt_verification_6.scala
Created Aug 14, 2019
Describes Step 6 of JWT verification
View jwt_verification_6.scala
// For reference
// received_jwt = abcde.fghij.klmno (header.payload.signature)
// Step 6.1
val received_signature = extract_sig(received_jwt) // klmno
// Step 6.2
val can_trust = (received_signature == expected_signature)
@calvincodes
calvincodes / jwt_verification_4_to_5.scala
Created Aug 14, 2019
Describes Step 4 to 5 of JWT verification
View jwt_verification_4_to_5.scala
val hash_of_rcvd_data = hash_alg(rcvd_data, secret_key) // Step 4
val expected_signature = base64UrlEncode(hash_of_rcvd_data) // Step 5
@calvincodes
calvincodes / jwt_verification_1_to_3.scala
Created Aug 14, 2019
Describes Step 1 to 3 of JWT verification
View jwt_verification_1_to_3.scala
// For reference
// received_jwt = abcde.fghij.klmno (header.payload.signature)
// Step 1
val received_header = extract_header(received_jwt) // abcde
// Step 2
val received_payload = extract_payload(received_jwt) // fghij
// Step 3
@calvincodes
calvincodes / payload.json
Created Aug 13, 2019
Sample JWT Payload
View payload.json
{
"id": "12345-abcde-67890-fghij",
"loginSource": "google_oauth",
"maxIdleTime": "1h"
}
View alice_jwt_payload.json
{
"msg": "Hi Bob, I will be able to attend the party."
}
@calvincodes
calvincodes / jwt_header.json
Last active Aug 13, 2019
Sample JWT Header
View jwt_header.json
{
"alg": "HS256",
"typ": "JWT"
}
View AWSUpdateSecret.scala
val updateSecretRequest =
new UpdateSecretRequest().
withSecretId(secretId).
withKmsKeyId(newKmsKeyId).
withSecretString(newSecretString)
awsSecretsManager.updateSecret(updateSecretRequest)
View Range for hybrid of color spaces
0.0 <= H <= 50.0 and 0.23 <= S <= 0.68
and R > 95 and G > 40 and B > 20 and R > G
and R > B and | R - G | > 15 and A > 15
You can’t perform that action at this time.