Skip to content

Instantly share code, notes, and snippets.

View nghiaht's full-sized avatar

Huỳnh Trọng Nghĩa nghiaht

View GitHub Profile
@nghiaht
nghiaht / 3des_using_node_builtin_crypto.js
Last active March 11, 2022 22:11
Sample codes for encrypting and decrypting by 3DES using node-forge or built-in crypto module
const crypto = require("crypto");
/**
* Encrypt 3DES using Node.js's crypto module *
* @param data A utf8 string
* @param key Key would be hashed by md5 and shorten to maximum of 192 bits,
* @returns {*} A base64 string
*/
function encrypt3DES(data, key) {
const md5Key = crypto.createHash('md5').update(key).digest("hex").substr(0, 24);
@howtomakeaturn
howtomakeaturn / example.js
Last active September 13, 2023 04:23
Fabric.js subclass working example, supporting clone - LabeledRect
fabric.LabeledRect = fabric.util.createClass(fabric.Rect, {
type: 'labeledRect',
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
label: this.get('label')
});
},