ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/security/Fog.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/security/Fog.java
Status
scanned
Type
file
Name
Fog.java
Extension
.java
Programming language
Java
Mime type
text/x-java
File type
Java source, ASCII text
Tag

      
    
Rootfs path

      
    
Size
2281 (2.2 KB)
MD5
5b9756452150e751c2cdaeeac540dda6
SHA1
5f95116cda87854c361779b37abfe56a761ab11a
SHA256
2162e8d16447747905b50a26edb47dd2fdade500804fa1454b37ebe8bcfdc97a
SHA512

      
    
SHA1_git
3aea0cbc972af64418927e12212dfdbcfdcb71a1
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Fog.java | 2.2 KB |

/* * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.security; import org.h2.util.Bits; /** * A pseudo-encryption algorithm that makes the data appear to be * encrypted. This algorithm is cryptographically extremely weak, and should * only be used to hide data from reading the plain text using a text editor. */ public class Fog implements BlockCipher { private int key; @Override public void encrypt(byte[] bytes, int off, int len) { for (int i = off; i < off + len; i += 16) { encryptBlock(bytes, bytes, i); } } @Override public void decrypt(byte[] bytes, int off, int len) { for (int i = off; i < off + len; i += 16) { decryptBlock(bytes, bytes, i); } } private void encryptBlock(byte[] in, byte[] out, int off) { int x0 = Bits.readInt(in, off); int x1 = Bits.readInt(in, off + 4); int x2 = Bits.readInt(in, off + 8); int x3 = Bits.readInt(in, off + 12); int k = key; x0 = Integer.rotateLeft(x0 ^ k, x1); x2 = Integer.rotateLeft(x2 ^ k, x1); x1 = Integer.rotateLeft(x1 ^ k, x0); x3 = Integer.rotateLeft(x3 ^ k, x0); Bits.writeInt(out, off, x0); Bits.writeInt(out, off + 4, x1); Bits.writeInt(out, off + 8, x2); Bits.writeInt(out, off + 12, x3); } private void decryptBlock(byte[] in, byte[] out, int off) { int x0 = Bits.readInt(in, off); int x1 = Bits.readInt(in, off + 4); int x2 = Bits.readInt(in, off + 8); int x3 = Bits.readInt(in, off + 12); int k = key; x1 = Integer.rotateRight(x1, x0) ^ k; x3 = Integer.rotateRight(x3, x0) ^ k; x0 = Integer.rotateRight(x0, x1) ^ k; x2 = Integer.rotateRight(x2, x1) ^ k; Bits.writeInt(out, off, x0); Bits.writeInt(out, off + 4, x1); Bits.writeInt(out, off + 8, x2); Bits.writeInt(out, off + 12, x3); } @Override public int getKeyLength() { return 16; } @Override public void setKey(byte[] key) { this.key = (int) Bits.readLong(key, 0); } }
Detected license expression
mpl-2.0 AND epl-1.0
Detected license expression (SPDX)
MPL-2.0 AND EPL-1.0
Percentage of license text
2.91
Copyrights
- end_line: 2
  copyright: Copyright 2004-2023 H2 Group. Multiple-Licensed
  start_line: 2
Holders
- holder: H2 Group. Multiple-Licensed
  end_line: 2
  start_line: 2
Authors

      
    
License detections License expression License expression SPDX
mpl_2_0_and_epl_1_0-796bf8d7-f485-3520-923d-e6a4b1ecd2f3 mpl-2.0 AND epl-1.0 MPL-2.0 AND EPL-1.0
URL Start line End line
https://h2database.com/html/license.html 3 3
Package URL License Primary language
pkg:osgi/com.h2database.source@2.2.220