Skip to content

Instantly share code, notes, and snippets.

@Leigh-
Leigh- / EncryptCFDecryptNodeJS.txt
Last active April 18, 2016 06:01
Example of Encrypt in ColdFusion, Decrypt in Node.js
/*
Encrypt in ColdFusion
Summary
1. Generate a cryptographically random key with GenerateSecretKey(). Do *not* use a self generated
password, which is less secure.
2. Generate a random IV (initialization vector)][2] and decode into binary.
3. Encrypt the plain text with AES/CBC/PKCS5Padding
*/
@Leigh-
Leigh- / S3Wrapper.cfc
Last active August 28, 2018 12:15 — forked from christierney402/S3Wrapper.cfc
Amazon Web Services (AWS) S3 Wrapper for ColdFusion (Signature 4)
/**
* Amazon S3 REST Wrapper
* Version Date: 2016-04-12
*
* Copyright 2015 CF Webtools | cfwebtools.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@Leigh-
Leigh- / Sv4Util.cfc
Last active February 9, 2024 15:40
Amazon Web Services Signature 4 Utility for ColdFusion (Alpha)
/**
* Amazon Web Services Signature 4 Utility for ColdFusion
* Version Date: 2016-04-12 (Alpha)
*
* Copyright 2016 Leigh (cfsearching)
*
* Requirements: Adobe ColdFusion 10+
* AWS Signature 4 specifications: http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
*
* Licensed under the Apache License, Version 2.0 (the "License");
@Leigh-
Leigh- / EncodeRFC3986.cfm
Created April 18, 2016 05:57
Comparison of EncodeForURL, URLEncodedFormat and EncodeRFC3986 (UDF)
<cfscript>
/**
* URI encoding per RFC 3986, which has treats the following as unreserved: ALPHA / DIGIT / "-" / "." / "_" / "~"
* @text Text to encode
* @returns URI encoded text
*/
public function encodeRFC3986(required string text) {
// Requires CF10+
Local.encoded = encodeForURL(arguments.text);
// Reverse encoding of tilde "~"
@Leigh-
Leigh- / AWSSignature4-Task1.cfm
Last active July 17, 2018 08:20
ColdFusion: AWS Task 1: Create a Canonical Request for Signature Version 4
<!---
CFML translation of Amazon Web Services Example - Task 1:
http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html
--->
<h1>Task 1: Create a Canonical Request for Signature Version 4 (ColdFusion)</h1>
<div>
<strong>Canonical request pseudocode</strong>
<pre>CanonicalRequest = HTTPRequestMethod + '\n' +
CanonicalURI + '\n' +
CanonicalQueryString + '\n' +
@Leigh-
Leigh- / AWSSignature4-Task2.cfm
Created May 1, 2016 18:10
ColdFusion: AWS Task 2: Create a String to Sign for Signature Version 4
<!---
CFML translation of Amazon Web Services Example - Task 2:
http://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html
--->
<h1>Task 2: Create a String to Sign for Signature Version 4</h1>
<div>
<strong>Structure of string to sign</strong>
<pre>StringToSign = Algorithm + '\n' +
RequestDate + '\n' +
@Leigh-
Leigh- / AWSSignature4-Task3.cfm
Created May 1, 2016 18:17
ColdFusion: AWS Task 3: Calculate the AWS Signature Version 4
<!---
CFML translation of Amazon Web Services Example - Task 3:
http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html
--->
<h1>Task 3: Calculate the AWS Signature Version 4</h1>
<div>
<strong>Pseudocode for deriving a signing key</strong>
<pre>
kSecret = Your AWS Secret Access Key
@Leigh-
Leigh- / AWSSignature4-Task4.cfm
Created May 1, 2016 18:19
ColdFusion: AWS Task 4: Add the Signing Information to the Request
<!---
CFML translation of Amazon Web Services Example - Task 4:
http://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html
Note: Translation only includes generating Authorization header
--->
<h1>Task 4: Add the Signing Information to the Request</h1>
<div>
After you calculate the signature, you add it to the request. You can add the signing information to a request in one of two ways:
@Leigh-
Leigh- / Apple News API - CreateArticle
Last active July 6, 2016 20:24
Initial version of CreateArticle Example for Apple News API. Tested under CF11
<cfscript>
/*
IMPORTANT: Make sure fileGetMimeType("c:/path/article.json") returns the
correct mime type in your environment:
ie: Should return: "application/json"
... and not : "text/plain"
*/
// Modify these variables for your environment