Giter VIP home page Giter VIP logo

des's Introduction

Des

Des source code for js,perl and php.

Licensing and Usage

Several people have asked me about licensing issues, and whether it is possible to use this version of DES in a commercial or personal application. This page tries to answer that question, and also shows known places where this DES algorithm is being used.

About

I only started doing this in August 2008 so it's not complete. Please send me any other uses you find.

  • Encryptadoro - a widget for the Mac OS X dashboard for encrypting passwords
  • Omerta - for encrypting and decrypting messages
  • DES Password Pro - for creating multiple user Javascript login forms
  • e-Will - a safe way to send messages to friends in case something happens to you (added 31/8/2008)
  • Klepshydra - Mac widget for encrypting messages (added 7/9/2009)
  • Joomla Encryption Configuration - a Joomla extension for encrypting passwords and other data in your component (added 5/6/2010)

The project site: http://www.tero.co.uk/des

Usage

des (string key, string message, boolean encrypt, [integer mode, string iv, integer padding])
  • key
    The des function accepts an 8 character string as the key (this is 64 bits, but the algorithm only uses 56) for normal DES or a 24 character string for triple DES,
  • message A message string
  • encrypt A boolean to say whether the data should be encrypted or decrypted
  • mode An optional mode (0 for ECB and 1 for CBC, ECB is the default)
  • iv An optional 8 character string input vector (not used in ECB mode)
  • padding And the type of padding (0 for null or zero bytes, 1 for PKCS7, 2 for spaces and 3 for no padding at all). It returns the cipher text as a string.

Here are several examples showing how it can be used:

//encrypt using single DES (with an 8 byte key) in CBC mode
//with the given input vector and PKCS7 padding
des ("8bytekey", "This is the message.", 1, 1, "inputvec", 1);
//encrypt using triple DES (with a 24 byte key) in ECB mode
des ("this is a 24 byte key !!", "This is the message.", 1);
//decrypt using single DES in ECB mode
des ("8bytekey", "2384lf&*£90LSdsf", 0);

Licensing

The Javascript version of DES is based on a C version written and copyrighted by Eric Young as part of his SSL implementation. I went line by line through the C code, also following an in-depth description of the algorithm from another publication, and slowly built up the Javascript version. So as far as I am concerned the Javascript, Perl and PHP versions can be used in any way you would like, though I would like to be informed of any commercial usage. But I don't know if there are any other licensing implications. I would be very pleased if someone legally minded could tell me.

Source Code There is no warranty for this code and I cannot be held responsible for any problems arising from using it (including those caused by bugs). It has been tested to see if it produces correct output, but has not been robustly tested on different browsers, processors, or with a wide range of keys and messages. Any modifications to this code must be posted on this site. If you find any errors, bugs, security holes, or have any questions or comments please email us.

des's People

Contributors

ahuigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

des's Issues

there will be extra white space

        var key = "test";
        var message = "admin";
        var ciphertext = des (key, message, true, 0,'', 1);
        


        btoa(ciphertext)  // mDSUHsRcgOY=
        des(key, ciphertext, false) // admin���
	// CryptoJS
	const keyHex = CryptoJS.enc.Utf8.parse('test')
	const decrypted = CryptoJS.DES.decrypt(
		{
			iv: '',
			salt: '',
			ciphertext: CryptoJS.enc.Base64.parse(btoa(ciphertext))
		}, 
		keyHex,
		{
			mode: CryptoJS.mode.ECB,
			padding: CryptoJS.pad.Pkcs7
		}
	)
	decrypted.toString(CryptoJS.enc.Utf8) // admin

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.