public class PasswordEncrypter extends JFrame
JFrame.AccessibleJFrameFrame.AccessibleAWTFrameWindow.AccessibleAWTWindow, Window.TypeContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
static String |
CRYPT_PREFIX
Deprecated.
|
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabledCROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSORBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTDISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSEABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
PasswordEncrypter()
Creates new form PasswordEncrypter.
|
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
bytesFromChars(char[] chars,
boolean wipeInput)
Converts a
char[] into a byte[] assuming byte i is the high byte and byte i + 2 is the
low byte of a two byte char representation. |
static char[] |
charsFromBytes(byte[] bytes,
boolean wipeInput)
Converts a
byte[] into a char[] assuming byte i is the high byte and byte i + 2 is the
low byte of a two byte char representation. |
static char[] |
decrypt(char[] string,
boolean wipeInput)
Decrypts a given string that was created by
encrypt(char[], boolean). |
static String |
decryptString(String code)
Deprecated.
|
static char[] |
encrypt(char[] string,
boolean wipeInput)
Encrypts a given string using Password-based Encryption with MD5 and DES that can be decrypted using
decrypt(char[], boolean). |
static String |
encryptString(String pwd)
Deprecated.
|
static byte |
getWipe()
Get a random byte to wipe data.
|
static void |
main(String[] args)
main program.
|
static byte[] |
safeRead(InputStream propertyStream,
char[] property)
Reads a property as safe as possible.
|
static void |
wipe(byte[] bytes)
Wipes a given
byte[] using random bytes. |
static void |
wipe(char[] chars)
Wipes a given
char[] using random bytes. |
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateaddNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecoratedaddPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFrontadd, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetFont, postEvent@Deprecated public static String CRYPT_PREFIX
public static void main(String[] args) throws Exception
args - the command line argumentsException - throws Exeption if anything went wrong@Deprecated public static String decryptString(String code) throws PasswordEncrypterException
String with BlowfishEasy.code - String that should get decryptednull if code was set to nullPasswordEncrypterException - throws PasswordEncrypterExeption if anything went wrong@Deprecated public static String encryptString(String pwd) throws PasswordEncrypterException
String using BlowfishEasy.pwd - String that shoudl get encryptedStringPasswordEncrypterException - throws PasswordEncrypterExeption if anything went wrongpublic static char[] encrypt(char[] string,
boolean wipeInput)
throws PasswordEncrypterException
decrypt(char[], boolean). The caller is responsible for wiping the returned result himself. The given
array can automatically be wiped by passing true to the wipeInput parameter. All
temporary created data is immediately wiped, thus this implementation offers as little traces in memory as
possible.PasswordEncrypter.propertiesPasswordEncrypter.masterKeyde.cismet.toolsASCII characters, see
safeRead(java.io.InputStream, char[]). This operation also requires Salt as an input.
However, though it is not recommended, this implementation offers a default-Salt, if none is provided. The Salt
can be provided through the PasswordEncrypter.salt property within the
PasswordEncrypter.properties in the de.cismet.tools package. It must have a fixed length of
eight byte. If it is too small, missing bytes will be filled up using the default-Salt. If it is too big, only
the first eight bytes are used. Every character provided by the Salt property is interpreted as a single
byte, see safeRead(java.io.InputStream, char[]).string - the string to encryptwipeInput - whether to wipe the input array or notchar[] or null if the given array is
nullPasswordEncrypterException - if an error occurs during encryption, e.g. the PasswordEncrypter.properties
with the masterKey cannot be found, etc.safeRead(java.io.InputStream, char[])public static char[] decrypt(char[] string,
boolean wipeInput)
throws PasswordEncrypterException
encrypt(char[], boolean). The caller is responsible for
wiping the returned result himself. The given array can automatically be wiped by passing true to
the wipeInput parameter. All temporary created data is immediately wiped, thus this implementation
offers as little traces in memory as possible.decryptString(java.lang.String), too, for
compatibility reasonsPasswordEncrypter.propertiesPasswordEncrypter.masterKeyde.cismet.toolsASCII characters, see
safeRead(java.io.InputStream, char[]). This operation also requires Salt as an input.
However, though it is not recommended, this implementation offers a default-Salt, if none is provided. The Salt
can be provided through the PasswordEncrypter.salt property within the
PasswordEncrypter.properties in the de.cismet.tools package. It must have a fixed length of
eight byte. If it is too small, missing bytes will be filled up using the default-Salt. If it is too big, only
the first eight bytes are used. Every character provided by the Salt property is interpreted as a single
byte, see safeRead(java.io.InputStream, char[]).string - the string to decriptwipeInput - whether to wipe the input array or notchar[] or null if the given array is
null or the given string itself, if the string is not correctly formattedPasswordEncrypterException - if an error occurs during decryption, e.g. the PasswordEncrypter.properties
with the masterKey cannot be found or the given array is not base64 encoded,
etc.safeRead(java.io.InputStream, char[])public static char[] charsFromBytes(byte[] bytes,
boolean wipeInput)
byte[] into a char[] assuming byte i is the high byte and byte i + 2 is the
low byte of a two byte char representation. Thus the resulting char[] is half as long as the input array.bytes - bytes to be converted to charswipeInput - whether to wipe the input array or notIllegalArgumentException - if the length of the given byte array is not evenpublic static void wipe(byte[] bytes)
byte[] using random bytes. The array will only contain a random mess afterwards.bytes - the byte array to wipegetWipe()public static byte[] bytesFromChars(char[] chars,
boolean wipeInput)
char[] into a byte[] assuming byte i is the high byte and byte i + 2 is the
low byte of a two byte char representation. Thus the resulting byte[] is twice the size of the input array.chars - chars to be converted to byteswipeInput - whether to wipe the input array or notpublic static void wipe(char[] chars)
char[] using random bytes. The array will only contain a random mess afterwards.chars - the char array to wipegetWipe()public static byte getWipe()
SecureRandompublic static byte[] safeRead(InputStream propertyStream, char[] property) throws PasswordEncrypterException
String objects. The given stream will be used as is, it won't be closed nor reset. However, if the
InputStream.read() operation of this implementation will change some markers or similar they won't be
reset, too.IMPORTANT: Properties are supposed to be separated by a single '=' and terminated by a line feed or EOF.
IMPORTANT: Only ASCII encoded properties are currently supported
propertyStream - the stream to read fromproperty - the property to readbyte[]PasswordEncrypterException - throws PasswordEncrypterExeption if anything went wrongCopyright © 2012–2026 cismet GmbH. All rights reserved.