Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 ALL


  Implementing DESede/ECB/NoPadding cipher algorithm in GoLang

By default, GoLang doesn't provide the ECB mode cipher for DESede though there is CBC mode provided. In cases we need to encrypt/decrypt data with ECB mode, we need to implement those by ourselves. This mode is frequently used when encrypting/decrypting PIN block which is small block data less than 16 bytes.In this post, we will introduce how to implement the DESede/ECB/NoPadding algorithm in GoLang by using the existing cipher support. Here we will not cover how DESede works in detail, instead we will just cover the logic to make it work.Below is the sample code which can be used to encrypt/d...

7,772 0       GOLANG SAMPLE SECURITY DES DESEDE 3DES


  String.length() vs String.getBytes().length in Java

In Java, String.length() is to return the number of characters in the string, while String.getBytes().length is to return the number of bytes to represent the string with the specified encoding. By default, the encoding will be the value of system property file.encoding, the encoding name can be set manually as well by calling System.setProperty("file.encoding", "XXX"). For example, UTF-8, Cp1252. In many cases, String.length() will return the same value as String.getBytes().length, but in some cases it's not the same.String.length() is the number of UTF-16 code units needed to represent the s...

111,676 0       JAVA STRING ENCODING SAMPLE UTF8


  Permutation implementation in Java

Permutation is a very basic and important mathematic concept we learned in school. It has very practical applications in real world. For example, in football.In simple, permutation describes all possible ways of doing something. For example, there are six permutations of the set {1,2,3}, namely: (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), and (3,2,1). In general, for n items, there are n! number of permutations to arrange these items. How can we implement this algorithm in programming programming language such as Java? Below is a simple code snippet which uses the recursive method. It's quite...

7,719 4       JAVA PERMUTATION IMPLEMENTATION SAMPLE