Coder Social home page Coder Social logo

1c-jwt's Introduction

1C HMAC & JWT

This is a pure 1C implementation of RFC 2104 https://www.ietf.org/rfc/rfc2104.txt and RFC 7519 https://tools.ietf.org/html/rfc7519

Limitations

This implementation works only on 1C:Enterprise platform version 8.3.10.2168 or above.
The platform you may download here: https://1c-dn.com/user/updates/1c_enterprise_platform_training_version/
For JWT supported algorithm HS256 only.
HMAC function supports algorithms: MD5, SHA1, SHA256

PS: Since version 8.3.21 you may use AccessToken object to create JWT.
https://wonderland.v8.1c.ru/blog/autentifikatsiya-s-pomoshchyu-jwt-tokenov/

Installing

Download modules Cryptography.bsl and JWT.bsl. Put modules into the 1C application.

Usage

	
	// HMAC
	SecretKey = "key";
	StringToSign = "The quick brown fox jumps over the lazy dog";
	Signature = Cryptography.HMAC(
		GetBinaryDataFromString(SecretKey),
		GetBinaryDataFromString(StringToSign),
		HashFunction.SHA256);

	// JWT
	SecretKey = "secret";
	Payload = New Structure;
	Payload.Insert("sub", "1234567890");
	Payload.Insert("name", "John Doe");
	Payload.Insert("admin", True);
	
	Token = JWT.Encode(SecretKey, Payload);
	
	DecodedPayload = JWT.Decode(Token, SecretKey);
	

Credits and License

Author: Vasily Pintov [email protected]

License: MIT

1c-jwt's People

Contributors

pintov avatar sulfur17 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.