Encrypt/decrypt using update
Hi,
can someone give me an encrypt/decrypt pair of code samples that use the cipher.update() call.
i am trying it like that but apparently it doesn't work
byte[] temp = new byte[message.length/2];
byte[] temp2 = new byte[message.length/2];
System.arraycopy(message, 0, temp, 0, temp.length);
System.arraycopy(message, temp.length, temp2, 0, temp.length);
ciphertext = new byte[message.length];
System.arraycopy(symmetricCipher.update(temp), 0, ciphertext, 0, temp.length);
System.arraycopy(symmetricCipher.doFinal(temp2), 0, ciphertext, temp.length, temp.length);
ode]
>
I don't see how using the inputstream i would avoid
the memory error, when passing anything over
10,000,000. Unless you mean I split the input, and
write small chunks into disk as I encrypt them?Your basic problem is that you have the data as one large array. I don't know how and why you created this large array; I would not to create it unless there was no other way.
Since it does not make sense to create one large encrypted byte array and given that you have a byte array then you can use either
1) Create a ByteArrayInputStream and wrap it in a CipherinputStream. This would allow you to encrypt the array in a sequential manner a few KBytes at a time.
or
2) Encrypt the array a few KBytes at a time using a simple update(array, start, length) that returns the encrypted bytes.
But first, I would try to avoid creating the large 'cleartext' array.
Similar Messages
-
Error in running encryption/decryption using DES in Websphere Dev't Client
Hello!
I have a code used to encrypt / decrypt a string (password). I have already tested it using Netbeans and it is working. But when I tried to add the java code to an existing web project using Websphere Development Client,, javax.crypto.* is not recognized. Then I imported JCE.jar.
The java code contains no errors then, but when I started to run the project, it gives an Error 500. And below is the Console's error message:
E SRVE0026E: [Servlet Error]-[javax.crypto.spec.PBEKeySpec: method <init>([C[BI)V not found]: java.lang.NoSuchMethodError: javax.crypto.spec.PBEKeySpec: method <init>([C[BI)V not found[/b]
Have I missed something to add? Or other things that I should do upon importing this jar file?
Please help.
Advance thanks for your reply.
misyelI dont know what version of Java that my Websphere's using. But I am very sure that it is outdated. I am using Websphere 5.0. For Netbeans, it is JDK1.5.
I imported the JCE from JDK 1.5 on Websphere.
I think the code works perfectly fine. Actually it was my friend's code for encryption but they are using Eclipse for development (almost the same from Websphere but somehow different from it.)
My idea is that I cant match the versions of the jarfiles used in my project. As much as I wanted to change the imported jar files, I couldn't for when I replaced the existing jar files, more and more errors occur.
can we have any alternative ways of importing the jar files? or is there any other code that might help that will not use the JCE.jar?
I really appreciate your response. thanks
misyel -
Encrypt/Decrypt using REPLACE/TRANSLATE function
Hi,
Can someone please provide me any procedure/function which encrypts/decrypts a string using REPLACE/TRANSLATE function?
Thanks
Dinakarexample with TRANSLATE:
CREATE OR REPLACE function temp_encrypt (p_value IN VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN(TRANSLATE(p_value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'BCDEFGHIJKLMNOPQRSTUVWXYZA'));
END;
CREATE OR REPLACE function temp_decrypt (p_value IN VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN(TRANSLATE(p_value, 'BCDEFGHIJKLMNOPQRSTUVWXYZA', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'));
END;
SQL> SELECT temp_decrypt('MY TEST') FROM dual;
TEMP_DECRYPT('MYTEST')
LX SDRS
SQL> SELECT temp_encrypt('LX SDRS') FROM dual;
TEMP_ENCRYPT('LXSDRS')
MY TESTyou may combine this with REPLACE() ... -
Crypt::cbc encrypt / decrypt using javax.crypto
I am having a bit of a time encrypting with crypt::cbc and decrypting with java. To get to the point, here is my code, perl first, java 2nd - I have tried to keep things very simple.
#!/usr/local/bin/perl -w
use strict;
use Crypt::CBC 2.30;
die "Need to specify a file" if(!(my $infile = shift));
my $key = q(nvA9s$233eOrlQG4);
my $iv = q(0123456701234567);
my $bufsize = 16384;
my $cipher = Crypt::CBC->new({
'key' => $key,
'iv' => $iv,
'header' => 'none',
'cipher' => 'Rijndael',
'keysize' => '16', #forced - default is 32 bytes
'padding' => 'standard', #PKCS5
'blocksize' => '16',
'literal_key' => '1', #do not MD5 hash key
open (FORIG,"$infile")|| die "can't open file: $!";
open (FCRYPT,">$infile.crypt")|| die "can't open file: $!";
$cipher->start('encrypting');
while(my $readsize = sysread(FORIG, my $buf, $bufsize)) {
print FCRYPT $cipher->crypt($buf);
print FCRYPT $cipher->finish();
close FCRYPT;
close FORIG;
now the java:
// i have elided the import stmts for brevity
public class AESEncrypter {
Cipher ecipher;
Cipher dcipher;
byte [] buf = new byte[1024];
public AESEncrypter() {
String strKey = "nvA9s$233eOrlQG4";
byte[] keyBytes = null;
try {
keyBytes = strKey.getBytes("UTF-8");
} catch(java.io.UnsupportedEncodingException ex) {
ex.printStackTrace();
byte[] iv = new byte[] { 0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7 };
IvParameterSpec ivSpec = new IvParameterSpec(iv);
try {
ecipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
try {
SecretKeySpec key = new SecretKeySpec(keyBytes, "AES");
ecipher.init(Cipher.ENCRYPT_MODE, key, ivSpec);
dcipher.init(Cipher.DECRYPT_MODE, key, ivSpec);
} catch (InvalidKeyException e1) {
e1.printStackTrace();
} catch (InvalidAlgorithmParameterException e1) {
e1.printStackTrace();
public void encrypt(InputStream in, OutputStream out) {
try {
out = new CipherOutputStream(out, ecipher);
int numRead = 0;
while((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
out.close();
} catch(java.io.IOException e) {
e.printStackTrace();
public void decrypt(InputStream in, OutputStream out) {
try {
out = new CipherOutputStream(out, dcipher);
int numRead = 0;
while((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
out.close();
} catch(java.io.IOException e) {
e.printStackTrace();
public static void main(String args[]) {
if(args.length != 1) {
System.out.println("Usage: java AESEncrypter filename");
System.exit(0);
AESEncrypter encrypter = new AESEncrypter();
try {
// encrypter.encrypt(new FileInputStream(args[0]), new FileOutputStream("Java_encrypted.txt"));
encrypter.decrypt(new FileInputStream(args[0]), new FileOutputStream("Java_decrypted.txt"));
} catch (java.io.FileNotFoundException ex) {
ex.printStackTrace();
so with file named whoop.txt containing the following contents:
whoop
whoop
whoop
whoop
I do:
$>./encrypt.pl whoop.txt
and get the resulting file whoop.txt.crypt. then I do
$>java AESEncrypter whoop.txt.crypt
and get the resulting file Java_decrypted.txt. when I do a hex dump of this file:
$>dump.pl Java_decrypted.txt
i get the following
/0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /A /B /C /D /E /F 0123456789ABCDEF
0000 : 47 58 5F 5F 40 3A 47 58 5F 5F 40 3A 47 58 5F 5F GX__@:GX__@:GX__
0010 : 70 0A 77 68 6F 6F 70 0A p.whoop.
I have tried to ensure that everything matches between the perl and java code, however I am obviously missing something. Thanks in advance for any ideas!
Greggi have hardcoded the IV in perl as:
my $iv = q(0123456701234567);
and in the .java file as:
byte[] iv = new byte[] { 0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7 };
IvParameterSpec ivSpec = new IvParameterSpec(iv)
Are these not compatible?
thanks - gh -
Newbie need to encrypt/decrypt using password
Hi all,
I need to encrypt some data store it in database and retrieve it at another time and decrypt it. The user will supply the password. I have no idea on how to do it. This encryption must be very strong like PGP. I can use the jars provided by Sun.
rgds
Antony Paulpackage login.view;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
//import org.myorg.SystemUnavailableException;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import sun.misc.CharacterEncoder;
public final class PasswordService
private static PasswordService instance;
private PasswordService()
public synchronized String encrypt(String plaintext) throws Exception
MessageDigest md = null;
try
md = MessageDigest.getInstance("SHA"); //step 2
catch(NoSuchAlgorithmException e)
throw new Exception(e.getMessage());
try
md.update(plaintext.getBytes("UTF-8")); //step 3
catch(UnsupportedEncodingException e)
throw new Exception(e.getMessage());
byte raw[] = md.digest(); //step 4
String hash = (new BASE64Encoder()).encode(raw); //step 5
return hash; //step 6
public static synchronized PasswordService getInstance() //step 1
if(instance == null)
return new PasswordService();
else
return instance;
You can use this classas below.................
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
HttpSession session=request.getSession(true);
//HttpSession session = new HttpSession();
LoginBean login =(login.view.LoginBean) form;
String LoginName= login.getLoginName();
String LoginPassword = login.getLoginPassword();
try
session.setAttribute("LoginPassword",PasswordService.getInstance().encrypt(LoginPassword));
catch(Exception e)
session.setAttribute("LoginName",LoginName);
return mapping.findForward("success");
} -
Better Encryption/Decryption Method - SMIME or PGP ?
1. Which is the default encryption/decryption method provided in BizTalk Server ?
2. What is PGP Encryption/Decryption ?
3. What is SMIME Encryption/Decryption ?
4. Which is better out of the two ?There is no default encryption/decryption method provided in BizTalk Server. BizTalk uses encryption/decryption using certificates (when you use certificates ). More about them here.
BizTalk Server : Encrypting and Decrypting a Message.
Pretty Good Privacy (PGP) is a data encryption and decryption computer program that provides cryptographic privacy and authentication for data communication.
Soruce: Wiki. In Specific to BizTalk, messages are encrypted/decrypted at the entry point into BizTalk, right place is in pipeline using custom pipeline component. There is one available
which you can learn more here.
https://code.msdn.microsoft.com/windowsdesktop/BizTalk-Sample-PGP-ebcbc8b2. Also there is a thrid party adapter and pipeline component available to implement extensive suite of PGP features in BizTalk-
https://www.eldos.com/bizcrypto/biztalk-pgp-adapter-pipeline.php
S/MIME (Secure/Multipurpose Internet Mail Extensions) is a standard for
public keyencryption and
signing of MIME data. S/MIME is on an
IETFstandards track and defined in a number of documents, most importantly RFCs 3369, 3370, 3850 and 3851. S/MIME was originally developed by
RSA Data Security Inc.
soruce Wiki. In BizTalk, when you use certificates with two-key security, it supports public key encryption of outbound messages and decryption of inbound messages based on Secure Multipurpose
Internet Mail Extensions (S/MIME). BizTalk Server uses S/MIME version 3 for encryption of outbound messages, and S/MIME versions 2 and 3 for decryption of inbound messages. Reference:
http://msdn.microsoft.com/en-us/library/aa559843.aspx
When you discuss about which is more native, I would choose S/MIME which can be implemented with certificates and out-of-MIME pipeline components.
If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply. -
B2B - SFTP - Encrypt data using PGP
Hello,
I am hearing / reading mixed comments on using PGP encryption / decryption using the SFTP Transport in Oracle B2B.
The requirement is the data needs to be encrypted during the transport between the trading partners. The SFTP server houses the PGP encrypted data, B2B should be able to listen, pick and decrypt and process the files.
Is this possible in Oracle SOA Suite 11g? If yes, could you please point me to any documentation that explains configuring B2B to decrypt a PGP encrypted file.
Thanks in advance,
VenkateshI think most comments you read about this would have said that B2B SFTP cannot handle PGP encryption. This is true. B2B out-of-box does not support PGP encryption/decription. Most people suggest using Java callout.
~Ismail. -
html,body{padding:0;margin:0;font-family:Verdana,Geneva,sans-serif;background:#fff;}html{font-size:100%}body{font-size:.75em;line-height:1.5;padding-top:1px;margin-top:-1px;}h1{font-size:2em;margin:.67em 0}h2{font-size:1.5em}h3{font-size:1.16em}h4{font-size:1em}h5{font-size:.83em}h6{font-size:.7em}p{margin:0
0 1em;padding:0 .2em}.t-marker{display:none;}.t-paste-container{;left:-10000px;width:1px;height:1px;overflow:hidden}ul,ol{padding-left:2.5em}a{color:#00a}code, pre{font-size:1.23em}
I get this message on two different machines installing SQL2014 developer edition, a Windows 7 and a Windows 8 machine. Both machines have SQL2005 through SQL2012 developer machines installed and working great. I have tried uninstalling all SQL2014 stuff and
installing again making sure I was running as an Administrator to no avail.
How do I look at sys.key_encryptionswhen the server will not start to finish installation?
The links in the log only provide the "We're Sorry" message.
This is the first error dialog info
TITLE: Microsoft SQL Server 2014 Setup
The following error has occurred:
Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
For help, click: http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft%20SQL%20Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=12.0.2000.8&EvtType=0xD15B4EB2%25400x4BDAF9BA%25401306%254026
The SQL Server error log has the message in the title.
2014-04-04 17:02:17.49 Server Microsoft SQL Server 2014 - 12.0.2000.8 (X64)
Feb 20 2014 20:04:26
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
2014-04-04 17:02:17.49 Server UTC adjustment: -4:00
2014-04-04 17:02:17.49 Server (c) Microsoft Corporation.
2014-04-04 17:02:17.49 Server All rights reserved.
2014-04-04 17:02:17.49 Server Serverprocess ID is 9236.
2014-04-04 17:02:17.49 Server System Manufacturer: 'Hewlett-Packard', System Model: 'HP EliteBook8760w'.
2014-04-04 17:02:17.49 Server Authentication mode is MIXED.
2014-04-04 17:02:17.49 Server Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\Log\ERRORLOG'.
2014-04-04 17:02:17.49 Server The service account is 'NT Service\MSSQL$SQL2014'. This is an informational message; no user action is required.
2014-04-04 17:02:17.49 Server Registry startup parameters:
-d C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\DATA\master.mdf
-e C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\Log\ERRORLOG
-l C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\DATA\mastlog.ldf
2014-04-04 17:02:17.49 Server Command Line Startup Parameters:
-s "SQL2014"
-m "SqlSetup"
-Q
-q "SQL_Latin1_General_CP1_CI_AS"
-T 4022
-T 4010
-T 3659
-T 3610
-T 8015
2014-04-04 17:02:17.79 Server SQL Server detected 1 sockets with 4 cores per socket and 8 logical processors per socket, 8 total logical processors; using 8 logical processors based on SQL Server licensing. This is an informational message;
no user action is required.
2014-04-04 17:02:17.79 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2014-04-04 17:02:17.79 Server Detected 8142 MB of RAM. This is an informational message; no user action is required.
2014-04-04 17:02:17.80 Server Using conventional memory in the memory manager.
2014-04-04 17:02:17.92 Server Default collation: SQL_Latin1_General_CP1_CI_AS (us_english1033)
2014-04-04 17:02:17.95 Server Perfmoncounters for resource governor pools and groups failed to initialize and are disabled.
2014-04-04 17:02:17.96 Server Query Store settings initialized with enabled = 1,
2014-04-04 17:02:17.97 Server The maximum number of dedicated administrator connections for this instance is '1'
2014-04-04 17:02:17.97 Server This instance of SQL Server last reported using a process ID of 8760 at 4/4/2014 5:02:08 PM (local) 4/4/2014 9:02:08 PM (UTC). This is an informational message only; no user action is required.
2014-04-04 17:02:17.97 Server Node configuration: node 0: CPU mask: 0x00000000000000ff:0 Active CPU mask: 0x00000000000000ff:0. This message provides a description of the NUMA configuration for this computer. This is an informational message
only. No user action is required.
2014-04-04 17:02:17.97 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2014-04-04 17:02:18.00 Server Database Mirroring Transport is disabled in the endpoint configuration.
2014-04-04 17:02:18.00 spid7s Warning ******************
2014-04-04 17:02:18.00 spid7s SQL Server started in single-user mode. This an informational message only. No user action is required.
2014-04-04 17:02:18.01 spid7s Starting up database 'master'.
2014-04-04 17:02:18.02 Server Software Usage Metrics is disabled.
2014-04-04 17:02:18.07 Server CLR version v4.0.30319 loaded.
2014-04-04 17:02:18.11 spid7s 8 transactions rolled forward in database 'master' (1:0). This is an informational message only. No user action is required.
2014-04-04 17:02:18.24 spid7s 0 transactions rolled back in database 'master' (1:0). This is an informational message only. No user action is required.
2014-04-04 17:02:18.25 spid7s Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2014-04-04 17:02:18.26 Server Common language runtime (CLR) functionality initialized using CLR version v4.0.30319 from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\.
2014-04-04 17:02:18.34 spid7s Service Master Key could not be decrypted using one of its encryptions. See sys.key_encryptions for details.
2014-04-04 17:02:18.40 spid7s SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2014-04-04 17:02:18.40 spid7s SQL Server Audit has started the audits. This is an informational message. No user action is required.
2014-04-04 17:02:18.44 spid7s SQL Trace ID 1 was started by login "sa".
2014-04-04 17:02:18.44 spid7s Server name is 'TOMGROSZKO-HP\SQL2014'. This is an informational message only. No user action is required.
2014-04-04 17:02:18.46 spid16s Error: 17190, Severity: 16, State: 1.
2014-04-04 17:02:18.46 spid16s Initializing the FallBackcertificate failed with error code: 1, state: 20, error number: 0.
2014-04-04 17:02:18.46 spid16s Unable to initialize SSL encryption because a valid certificate could not be found, and it is not possible to create a self-signed certificate.
2014-04-04 17:02:18.46 spid16s Error: 17182, Severity: 16, State: 1.
2014-04-04 17:02:18.46 spid16s TDSSNIClientinitialization failed with error 0x80092004, status code 0x80. Reason: Unable to initialize SSL support. Cannot find object or property.
2014-04-04 17:02:18.46 spid16s Error: 17182, Severity: 16, State: 1.
2014-04-04 17:02:18.46 spid16s TDSSNIClientinitialization failed with error 0x80092004, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. Cannot find object or property.
2014-04-04 17:02:18.46 spid16s Error: 17826, Severity: 18, State: 3.
2014-04-04 17:02:18.46 spid16s Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
2014-04-04 17:02:18.46 spid16s Error: 17120, Severity: 16, State: 1.
2014-04-04 17:02:18.46 spid16s SQL Server could not spawn FRunCommunicationsManagerthread. Check the SQL Server error log and the Windows event logs for information about possible related problems.
And a copy of the install log.
Overall summary:
Final result: Failed: see details below
Exit code (Decimal): -2061893606
Start time: 2014-04-04 16:23:39
End time: 2014-04-04 17:06:25
Requested action: Install
Setup completed with required actions for features.
Troubleshooting information for those features:
Next step for RS: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Next step for SQLEngine: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Next step for DQ: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Next step for FullText: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Next step for Replication: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Machine Properties:
Machine name: TOMGROSZKO-HP
Machine processor count: 8
OS version: Windows 7
OS service pack: Service Pack 1
OS region: United States
OS language: English (United States)
OS architecture: x64
Process architecture: 64 Bit
OS clustered: No
Product features discovered:
Product Instance Instance ID Feature
Language Edition Version Clustered Configured
SQL Server 2005 SQL2005 MSSQL.1 Database Engine Services
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 SQL2005 MSSQL.1 SQL Server Replication
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 SQL2005 MSSQL.1 Full-Text and Semantic Extractions for Search 1033
Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 SQL2005 MSSQL.1 SharedTools
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 SQL2005 MSSQL.2 Analysis Services
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 SQL2005 MSSQL.3 Reporting Services - Native
1033 Developer Edition (64-bit) 9.00.1399.06 No Yes
SQL Server 2005 DTS
1033 Developer Edition (64-bit) 9.4.5069 No
Yes
SQL Server 2005 Tools
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 ToolsClient
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 ToolsClient\Connectivity
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 ToolsDocument
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 ToolsDocument\BOL
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 ToolsDocument\Samples
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2005 NS
1033 Developer Edition (64-bit) 9.4.5069 No Yes
SQL Server 2008 R2 SQL2008R2 MSSQL10_50.SQL2008R2 Database Engine Services 1033
Developer Edition 10.51.2550.0 No Yes
SQL Server 2008 R2 SQL2008R2 MSSQL10_50.SQL2008R2 SQL Server Replication 1033
Developer Edition 10.51.2550.0 No Yes
SQL Server 2008 R2 SQL2008R2 MSSQL10_50.SQL2008R2 Full-Text and Semantic Extractions for Search 1033 Developer
Edition 10.51.2500.0 No Yes
SQL Server 2008 R2 SQL2008R2 MSAS10_50.SQL2008R2 Analysis Services 1033
Developer Edition 10.51.2500.0 No Yes
SQL Server 2008 R2 SQL2008R2 MSRS10_50.SQL2008R2 Reporting Services - Native 1033
Developer Edition 10.51.2550.0 No Yes
SQL Server 2008 R2 Management Tools - Basic
1033 Developer Edition 10.51.2550.0 No Yes
SQL Server 2008 R2 Management Tools - Complete
1033 Developer Edition 10.51.2500.0 No Yes
SQL Server 2008 R2 Client Tools Connectivity
1033 Developer Edition 10.51.2500.0 No Yes
SQL Server 2008 R2 Client Tools Backwards Compatibility
1033 Developer Edition 10.51.2500.0 No Yes
SQL Server 2008 R2 Client Tools SDK
1033 Developer Edition 10.51.2500.0 No Yes
SQL Server 2008 R2 Integration Services
1033 Developer Edition 10.51.2550.0 No Yes
SQL Server 2012 SQL2012 MSSQL11.SQL2012 Database Engine Services 1033
Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 SQL2012 MSSQL11.SQL2012 SQL Server Replication 1033
Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 SQL2012 MSSQL11.SQL2012 Full-Text and Semantic Extractions for Search 1033
Developer Edition 11.1.3000.0 No Yes
SQL Server 2012 SQL2012 MSSQL11.SQL2012 Data Quality Services 1033
Developer Edition 11.1.3000.0 No Yes
SQL Server 2012 SQL2012 MSAS11.SQL2012 Analysis Services
1033 Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 SQL2012 MSRS11.SQL2012 Reporting Services - Native 1033
Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 Management Tools - Basic
1033 Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 Management Tools - Complete
1033 Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 Client Tools Connectivity
1033 Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 Client Tools Backwards Compatibility
1033 Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 Client Tools SDK
1033 Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 BIDS
1033 Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 SQL Server Data Tools - Business
Intelligence for Visual Studio 2012 1033 11.1.3402.0 No Yes
SQL Server 2012 Integration Services
1033 Developer Edition 11.1.3128.0 No Yes
SQL Server 2012 LocalDB
1033 Express Edition 11.1.3128.0 No Yes
SQL Server 2012 Master Data Services
1033 Developer Edition 11.1.3000.0 No Yes
Package properties:
Description: Microsoft SQL Server 2014
ProductName: SQL Server 2014
Type: RTM
Version: 12
SPLevel: 0
Installation location: C:\Downloads\SQL2014\SQL\x64\setup\
Installation edition: Developer
Product Update Status:
None discovered.
User Input Settings:
ACTION: Install
ADDCURRENTUSERASSQLADMIN: false
AGTSVCACCOUNT: NT Service\SQLAgent$SQL2014
AGTSVCPASSWORD: *****
AGTSVCSTARTUPTYPE: Manual
ASBACKUPDIR: C:\SQLData\MSSQL\SQL2014\Backup
ASCOLLATION: Latin1_General_CI_AS
ASCONFIGDIR: C:\Program Files\Microsoft SQL Server\MSAS12.SQL2014\OLAP\Config
ASDATADIR: C:\SQLData\MSSQL\SQL2014\OLAP
ASLOGDIR: C:\SQLData\MSSQL\SQL2014\OLAP
ASPROVIDERMSOLAP: 1
ASSERVERMODE: MULTIDIMENSIONAL
ASSVCACCOUNT: NT Service\MSOLAP$SQL2014
ASSVCPASSWORD: <empty>
ASSVCSTARTUPTYPE: Automatic
ASSYSADMINACCOUNTS: TomGroszko-HP\Tom Groszko
ASTEMPDIR: C:\SQLData\MSSQL\SQL2014\OLAP
BROWSERSVCSTARTUPTYPE: Automatic
CLTCTLRNAME: <empty>
CLTRESULTDIR: <empty>
CLTSTARTUPTYPE: 0
CLTSVCACCOUNT: <empty>
CLTSVCPASSWORD: <empty>
CLTWORKINGDIR: <empty>
COMMFABRICENCRYPTION: 0
COMMFABRICNETWORKLEVEL: 0
COMMFABRICPORT: 0
CONFIGURATIONFILE: C:\Program Files\Microsoft SQL Server\120\Setup Bootstrap\Log\20140404_162339\ConfigurationFile.ini
CTLRSTARTUPTYPE: 0
CTLRSVCACCOUNT: <empty>
CTLRSVCPASSWORD: <empty>
CTLRUSERS: <empty>
ENABLERANU: false
ENU: true
ERRORREPORTING: true
FEATURES: SQLENGINE, REPLICATION, FULLTEXT, DQ, AS, RS, RS_SHP, RS_SHPWFE, DQC, CONN, IS, BC, SDK, BOL, SSMS, ADV_SSMS, MDS
FILESTREAMLEVEL: 3
FILESTREAMSHARENAME: SQL2014
FTSVCACCOUNT: NT Service\MSSQLFDLauncher$SQL2014
FTSVCPASSWORD: <empty>
HELP: false
IACCEPTSQLSERVERLICENSETERMS: true
INDICATEPROGRESS: false
INSTALLSHAREDDIR: c:\Program Files\Microsoft SQL Server\
INSTALLSHAREDWOWDIR: c:\Program Files (x86)\Microsoft SQL Server\
INSTALLSQLDATADIR: <empty>
INSTANCEDIR: C:\Program Files\Microsoft SQL Server\
INSTANCEID: SQL2014
INSTANCENAME: SQL2014
ISSVCACCOUNT: NT Service\MsDtsServer120
ISSVCPASSWORD: <empty>
ISSVCSTARTUPTYPE: Automatic
MATRIXCMBRICKCOMMPORT: 0
MATRIXCMSERVERNAME: <empty>
MATRIXNAME: <empty>
NPENABLED: 0
PID: *****
QUIET: false
QUIETSIMPLE: false
ROLE: <empty>
RSINSTALLMODE: DefaultNativeMode
RSSHPINSTALLMODE: SharePointFilesOnlyMode
RSSVCACCOUNT: NT Service\ReportServer$SQL2014
RSSVCPASSWORD: <empty>
RSSVCSTARTUPTYPE: Automatic
SAPWD: *****
SECURITYMODE: SQL
SQLBACKUPDIR: C:\SQLData\MSSQL\SQL2014\Backup
SQLCOLLATION: SQL_Latin1_General_CP1_CI_AS
SQLSVCACCOUNT: NT Service\MSSQL$SQL2014
SQLSVCPASSWORD: <empty>
SQLSVCSTARTUPTYPE: Automatic
SQLSYSADMINACCOUNTS: TomGroszko-HP\Tom Groszko
SQLTEMPDBDIR: C:\SQLData\MSSQL\SQL2014\Engine
SQLTEMPDBLOGDIR: <empty>
SQLUSERDBDIR: C:\SQLData\MSSQL\SQL2014\Engine
SQLUSERDBLOGDIR: <empty>
SQMREPORTING: true
TCPENABLED: 0
UIMODE: Normal
UpdateEnabled: true
UpdateSource: MU
USEMICROSOFTUPDATE: false
X86: false
Configuration file: C:\Program Files\Microsoft SQL Server\120\Setup Bootstrap\Log\20140404_162339\ConfigurationFile.ini
Detailed results:
Feature: Management Tools - Complete
Status: Passed
Feature: Client Tools Connectivity
Status: Passed
Feature: Client Tools SDK
Status: Passed
Feature: Client Tools Backwards Compatibility
Status: Passed
Feature: Management Tools - Basic
Status: Passed
Feature: Reporting Services - Native
Status: Failed: see logs for details
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Component name: SQL Server Database Engine Services Instance Features
Component error code: 0x851A001A
Error description: Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=12.0.2000.8&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
Feature: Database Engine Services
Status: Failed: see logs for details
Reason for failure: An error occurred during the setup process of the feature.
Next Step: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Component name: SQL Server Database Engine Services Instance Features
Component error code: 0x851A001A
Error description: Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=12.0.2000.8&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
Feature: Data Quality Services
Status: Failed: see logs for details
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Component name: SQL Server Database Engine Services Instance Features
Component error code: 0x851A001A
Error description: Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=12.0.2000.8&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
Feature: Full-Text and Semantic Extractions for Search
Status: Failed: see logs for details
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Component name: SQL Server Database Engine Services Instance Features
Component error code: 0x851A001A
Error description: Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=12.0.2000.8&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
Feature: SQL Server Replication
Status: Failed: see logs for details
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Component name: SQL Server Database Engine Services Instance Features
Component error code: 0x851A001A
Error description: Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=12.0.2000.8&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
Feature: Master Data Services
Status: Passed
Feature: Integration Services
Status: Passed
Feature: Data Quality Client
Status: Passed
Feature: Analysis Services
Status: Passed
Feature: Reporting Services - SharePoint
Status: Passed
Feature: Reporting Services Add-in for SharePoint Products
Status: Passed
Feature: Documentation Components
Status: Passed
Rules with failures:
Global rules:
Scenario specific rules:
Rules report file: C:\Program Files\Microsoft SQL Server\120\Setup Bootstrap\Log\20140404_162339\SystemConfigurationCheck_Report.htm
Any suggestions for what step to take next will be appreciated.
Thanks
Tom G.Hi Tom,
Sorry for the delay. We can exclude the media factor since you were able to install it on VM with this media.
If I understand correctly, Shanky said “Abve message can also appear due to corrupt profile so deleteting old profile and creating new one and using this to install would also help.Make sure you always RK on setup.exe and select run as administrator” which
means your user account may be corrupted rather than the Virtual account. You can create a new Windows user account and use it to log into the system. Then, re-try the installation.
Additional information:
http://windows.microsoft.com/en-us/windows/create-user-account#create-user-account=windows-8
Thanks.
Tracy Cai
TechNet Community Support -
How can I encrypt/decrypt data in Forms using a specified Package?
Hi All,
I have searched in the Internet for ecnrypting/decrypting data in Forms.
That is when I want to query the data outside the Form Application it will be encypted, otherwise if I want to query it in the form application it will be dycrypted
I found this package:
CREATE OR REPLACE PACKAGE Encrypt_pkg AS
FUNCTION encrypt (p_text IN VARCHAR2) RETURN RAW;
FUNCTION decrypt (p_raw IN RAW) RETURN VARCHAR2;
END Encrypt_pkg;
CREATE OR REPLACE PACKAGE BODY Encrypt_pkg AS
-- All VARCHAR2 inputs are padded to multiples of 8 charaters,
-- with the encryption key also being a multiple of 8 charaters.
-- The encryption key and padding characters can be altered to suit.
g_key RAW(32767) := UTL_RAW.cast_to_raw('12345678');
g_pad_chr VARCHAR2(1) := '';
PROCEDURE padstring (p_text IN OUT VARCHAR2);
FUNCTION encrypt (p_text IN VARCHAR2) RETURN RAW IS
l_text VARCHAR2(32767) := p_text;
l_encrypted RAW(32767);
BEGIN
padstring(l_text);
DBMS_OBFUSCATION_TOOLKIT.desencrypt(input => UTL_RAW.cast_to_raw(l_text),
key => g_key,
encrypted_data => l_encrypted);
RETURN l_encrypted;
END;
FUNCTION decrypt (p_raw IN RAW) RETURN VARCHAR2 IS
l_decrypted VARCHAR2(32767);
BEGIN
DBMS_OBFUSCATION_TOOLKIT.desdecrypt(input => p_raw,
key => g_key,
decrypted_data => l_decrypted);
RETURN RTrim(UTL_RAW.cast_to_varchar2(l_decrypted), g_pad_chr);
END;
PROCEDURE padstring (p_text IN OUT VARCHAR2) IS
l_units NUMBER;
BEGIN
IF LENGTH(p_text) MOD 8 > 0 THEN
l_units := TRUNC(LENGTH(p_text)/8) + 1;
p_text := RPAD(p_text, l_units * 8, g_pad_chr);
END IF;
END;
END Encrypt_pkg;
** Now How can I use this package to encrypt/decrypt data in the form as I said Plz???<p>Read this article and go to chapter 2.3.2.</p>Inserts, Update and Delete orders are managed by a stored procedure. In the sample dialog, the Select is handled by the emp_pkg.emp_query() stored function:
PROCEDURE emp_query(emp_data IN OUT emptab) IS
ii NUMBER;
CURSOR empselect IS
SELECT empno, ename, job, sal, comm FROM emp
ORDER BY ename ;
BEGIN
OPEN empselect;
ii := 1;
LOOP
FETCH empselect INTO
emp_data( ii ).empno,
emp_data( ii ).ename,
emp_data( ii ).job,
emp_data( ii ).sal,
emp_data( ii ).comm;
EXIT WHEN empselect%NOTFOUND;
ii := ii + 1;
END LOOP;
END emp_query;In your case, all you have to do is th use your decrypt() function in the cursor definition:
CURSOR empselect IS
SELECT decrypt(empno), decrypt(ename), decrypt(job), decrypt(sal), comm FROM emp
ORDER BY ename ;
...For Insert and Update events, use the crypt() function in the related stored procedures.
PROCEDURE emp_insert2(t IN emptab) IS
BEGIN
FOR i IN t.first..t.last LOOP
INSERT INTO emp (empno, ename, job, sal, comm)
VALUES(crypt(t(i).empno), crypt(t(i).ename), crypt(t(i).job), crypt(t(i).sal, t(i).comm));
END LOOP ;
END emp_insert2;Idem for the Update procedure.
Francois -
Encrypt/Decrypt data, multiple public keys using Bouncy castle api?
Hi all.
I need to implement encrypt/decrypt functionality of some data with many public keys using bouncy castle api and EnvelopedData class in java 1.4 SE.
Could someone give me examples how to do it. I searched whole the internet and i could not find simple example.Hi thanks very much.
I had a quick look at the examples. I will see if they could help me.
Here is more specific what i want:
Encrypt data with multiple public keys that are kept in .pkcs12 file.
And decrypt the data using coresponding private key after that.
I must use bouncy castle api for java 1.4 se.
Best regards
Edited by: menchev on Nov 13, 2008 8:26 AM -
Encrypt and decrypt using ECB mode
Dear All,
I'm looking the way to convert special character to hex and perform the encryption
Example : (All are dummy values )
Encryption key = K (Double length and using triple-DES)
Clear test (C) 1234AB=C6578ABE3 -----(Encode) ------------>After encoding the data should 0-F (ABC12E340987EA12) --------(Encrypt using K)------>Ciper data ( ACF1BE547659AC34) ------->and sending to another server.
At server level
Ciper data( ACF1BE547659AC34) ------>(Decrypt using K)------>Getting encoding value (ABC12E340987EA12)-------->(Decode)------>Clear test (C) = 1234AB=C6578ABE3 -----------> and processing
Q1. Is there any encoding method that can be used ?
Note : Really I'm not in position to change length of clear test (such as encoding asciii ) .
RegardsThanks
I have send the my test code
import java.security.Provider;
import java.security.Security;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
public class Encrypter {
private static Provider PR = null;
private static SecretKey KEY = null;
public static void init() throws Exception{
PR = new com.sun.crypto.provider.SunJCE();
Security.addProvider(PR);
KeyGenerator desKeyGen = KeyGenerator.getInstance("DESede", PR);
desKeyGen.init(112);
KEY= desKeyGen.generateKey();
public static byte[] encrypt(byte[] clearBytes) throws Exception {
Cipher cipher = Cipher.getInstance("DESede/ECB/NoPadding", PR.getName());
cipher.init(Cipher.ENCRYPT_MODE,KEY);
return cipher.doFinal(clearBytes);
public static byte[] decrypt(byte[] encr) throws Exception {
Cipher cipher = Cipher.getInstance("DESede/ECB/NoPadding", PR.getName());
cipher.init(Cipher.DECRYPT_MODE, KEY);
return cipher.doFinal(encr);
static String byteArrayToHexString(byte in[])
byte ch = 0x00;
int i = 0;
if (in == null || in.length <= 0)
return null;
String pseudo[] = {"0", "1", "2","3", "4", "5", "6", "7", "8","9", "A", "B", "C", "D", "E", "F"};
StringBuffer out = new StringBuffer(in.length * 2);
while (i < in.length)
ch = (byte) (in[i] & 0xF0); // Strip off high nibble
ch = (byte) (ch >>> 4); // shift the bits down
ch = (byte) (ch & 0x0F); // must do this is high order bit is on!
out.append(pseudo[ (int) ch]); // convert the nibble to a String Character
ch = (byte) (in[i] & 0x0F); // Strip off low nibble
out.append(pseudo[ (int) ch]); // convert the nibble to a String Character
i++;
String rslt = new String(out);
return rslt;
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2){
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
return data;
public static void main(String[] args) {
String clearString = "1234AB=C6578ABE3";
byte clearByte[] = hexStringToByteArray(clearString);
try {
init();
System.out.println("Clear data : "+clearString);
byte enrByte[] = encrypt(clearByte);
System.out.println("Encrypted data : "+byteArrayToHexString(enrByte));
byte decByte[] = decrypt(enrByte);
System.out.println("Decrypted data : "+byteArrayToHexString(decByte));
} catch (Exception e) {
e.printStackTrace();
Out put as follow,
Clear data : 1234AB=C6578ABE3
Encrypted data : 7EAEA4AB3FAA8DC1
Decrypted data : 1234ABFC6578ABE3
I'm not getting correct clear value after decrypting. (= character is getting replace with F)
Thanks
Edited by: sabre150 on Aug 9, 2012 2:46 PM
Moderator action : added [ code] tags to format the code. Please do this yourself in the future. -
HT5077 Decryption of Encrypted hfs+ using Lion OS X
How to Decrypt coreStorage (Encrypted hfs+ using Lion OS X) file system. because i forgot my encrypted drive(hfs+ encrypted) password or how to change password of this drive. please help me regarding this file system as soon as possible.
I'm afraid you're out of luck. The whole purpose of encryption is so it can be accessed only by someone with the password.
Is this your OSX drive? If so, did you record the Recovery Key? And/or register it with Apple? If you did, follow the procedures in OS X Lion: About FileVault 2.
Note this in the Additional Information section:
"Please take note that the encryption used in FileVault 2 will make accessing data on your encrypted drive impossible without the permitted user accounts' passwords or the recovery key. When you choose to turn on FileVault, you will no longer be able to auto-login. Take great care in choosing an account password that you feel is both secure and easy for you to remember. When enabling FileVault, carefully write it down or be certain to make a copy of exactly what is shown and store it outside of your encrypted disk. If choosing to store your recovery key with Apple, take great care in choosing your questions and providing answers you can, if needed, clearly convey to an AppleCare phone support advisor." (emphasis added) -
Encryption/Decryption failure for pdf and MSWord files
Hi,
Is there anybody to help me to find out what is wrong with my class (listing below)? I am sucessfuly using this class to encrypt and decrypt txt, html files but for unknown reasons I am unable to use it for e.g. pdf files. The encrypion somehow works but any atempt to decrypt is a failure.
/* This class accepts an input file, encrypts/decrypts it using DES algorithm and
writes the encrypted/decrypted output to an output file. DES is used in Cipher
Block Chaining mode with PKCS5Padding padding scheme. Note that DES is a symmetric
block cipher that uses 64-bit keys for encryption. A password of length no less
than 8 is to be passed to the encryptFile/ decryptFile methods. This password is
used to generate the encryption key. All exception handling is to be done by
calling methods. These exceptions are thrown by encryptFile/ decryptFile methods.
The input buffer is 64 bytes, 8 times the key size.
import java.io.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.*;
import java.security.spec.*;
public class Crypto
public Crypto(FileInputStream inStream_, FileOutputStream outStream_)
fInputStream_ = inStream_;
fOutputStream_ = outStream_;
public void encryptFile(String password_) throws InvalidKeySpecException, InvalidKeyException,
InvalidAlgorithmParameterException, IllegalStateException, IOException, Exception
DataOutputStream dataOutStream_ = new DataOutputStream(fOutputStream_);
// key generation
SecretKey encryptKey_ = createEncryptionKey(password_);
// Cipher initialization
Cipher cipher_= Cipher.getInstance(cipherType);
cipher_.init(Cipher.ENCRYPT_MODE, encryptKey_);
// write initialization vector to output
byte[] initializationVector_ = cipher_.getIV();
dataOutStream_.writeInt(initializationVector_.length);
dataOutStream_.write(initializationVector_);
// start reading from input and writing encrypted data to output
while (true) {
inputLength_ = fInputStream_.read(input_);
if (inputLength_ ==-1) break;
byte[] output_ = cipher_.update(input_, inputOffset_, inputLength_);
if (output_ != null)
dataOutStream_.write(output_);
// finalize encryption and wrap up
byte[] output_ = cipher_.doFinal();
if (output_ != null)
dataOutStream_.write(output_);
fInputStream_.close();
dataOutStream_.flush();
dataOutStream_.close();
public void decryptFile(String password_) throws IllegalStateException, IOException, Exception
DataInputStream dataInStream_ = new DataInputStream(fInputStream_);
// key generation
SecretKey encryptKey_ = createEncryptionKey(password_);
// read initialization vector from input
int ivSize_ = dataInStream_.readInt();
byte[] initializationVector_ = new byte[ivSize_];
dataInStream_.readFully(initializationVector_);
IvParameterSpec ivParamSpec_= new IvParameterSpec(initializationVector_);
// Cipher initialization
Cipher cipher_= Cipher.getInstance("DES/CBC/PKCS5Padding");
cipher_.init(Cipher.DECRYPT_MODE, encryptKey_, ivParamSpec_);
// start reading from input and writing decrypted data to output
while (true) {
inputLength_ = fInputStream_.read(input_);
if (inputLength_ ==-1) break;
byte[] output_ = cipher_.update(input_, inputOffset_, inputLength_);
if (output_ != null)
fOutputStream_.write(output_);
// finalize decryption and wrap up
byte[] output_ = cipher_.doFinal();
if (output_ != null)
fOutputStream_.write(output_);
fInputStream_.close();
fOutputStream_.flush();
fOutputStream_.close();
// the following method creates the encryption key using the supplied password
private SecretKey createEncryptionKey(String passwd_) throws InvalidKeySpecException,
InvalidKeyException, NoSuchAlgorithmException
byte[] encryptionKeyData_ = passwd_.getBytes();
DESKeySpec encryptionKeySpec_ = new DESKeySpec(encryptionKeyData_);
SecretKeyFactory keyFactory_ = SecretKeyFactory.getInstance(algorithm_);
SecretKey encryptionKey_ = keyFactory_.generateSecret(encryptionKeySpec_);
return encryptionKey_;
private FileInputStream fInputStream_;
private FileOutputStream fOutputStream_;
private final String algorithm_= "DES";
private final String cipherType= "DES/CBC/PKCS5Padding";
private byte[] input_ = new byte[64]; // The input buffer size is 64
private int inputLength_;
private final int inputOffset_= 0;
}Please can u give me refined code for me///
at [email protected]
Hi,
I found at least one thing wrong. In the decrypt
method you are reading from 'fInputStream_' rather
than 'dataInStream'.
Worked for me on MSWord after changing this!
Roger
// start reading from input and writing decrypted
ted data to output
while (true) {
inputLength_ = fInputStream_.read(input_);
if (inputLength_ ==-1) break;
byte[] output_ = cipher_.update(input_,
input_, inputOffset_, inputLength_);
if (output_ != null)
fOutputStream_.write(output_); -
Encrypt/decrypt same file with two different passwords
Hi everyone:
I'm quite new to Java and cryptography in general and have a theoretical question. Is the following scenario possible and how would it be implemented:
Two users with two passwords (say, a regular user and a superuser) encrypt, decrypt, read from and write to the same file. The secret key for encryption and decryption should be based on their passwords (generated from their passwords), i.e. not stored anywhere on the system.
I've been racking my brains but can't think of a way. Am I missing an obvious solution?
Can it be done?
Thanks,
MichaelI don't think you can avoid having more than just a password hash stored on the system. Using a combination of my approach and Jeff's approach I can implement this as long as you allow a password protected key store to be stored on each system. A given user's key store would contain his RSA private key and associated public key together with the admin user's RSA certificate (thought the admin user's public key could be stored in the program since it does not have to be kept private). The admin user's key store would contain only his RSA private and public keys.
Assume that the data file is to be create by a standard non-admin user. His code performs the following actions -
1) Generates a random symmetric algorithm key. Say a 128 bit AES key.
2) He write a digest of this to the output file.
3) He writes the random key encrypted with his public key to the file.
4) He writes his public key (or certificate) to the file.
5) He writes the random key encrypted with the admin users public key to the file.
6) He encrypts the data using the random key writes the result to the file.
This user can then update the file by
1) reading from the file the digest of the random key.
2) reading the random key encrypted with his public key.
3) Decrypting this encrypted random key using his private key extracted from his keystore.
4) Check the digest of this key to make sure he has the correct random key.
5) skipping his certificate and the random key encrypted using the admin user's public key.
5) Decrypting the data using the random key.
6) Update the data.
7) Re-encrypt the file as described in the first part using a new random key.
The admin user can
1) read from the file the digest of the random key.
2) skip the random key encrypted using the user's public key.
3) reading the user's public key from the file (for use later if the file needs to be updated).
4) read the random key encrypted using the admin's public key.
5) decrypting the random key using the admin's private key obtained from his key store.
6) check the digest of the random key to make sure it is correct.
7) decrypt the the data.
The admin can edit the data since he can re-encrypt the data in a similar manner to the way it was created in the first place. -
Encrypt/decrypt with des_cbc
Hi:
I have source code in c which can do encrypt and descrypt with des_cbc, now I want to implement the
java version with javax.crypto.*, but it tells java.security.InvalidKeyException
can anyone find the error for me?
I think the problem is at Cipher.getInstance(...), ...
java code: suppose the String data contains the encypted string.
/* get key factory */
keyFactory=KeyFactory.getInstance("RSA","SunRsaSign");
//cipher=Cipher.getInstance("DESede/CBC/PKCS5Padding");
cipher=Cipher.getInstance("DES/CBC/NoPadding");
System.out.println("get cipher");
/* get private key */
FileInputStream keyfis=new FileInputStream("/home/roger/private.der");
byte[] encKey=new byte[keyfis.available()];
keyfis.read(encKey);
keyfis.close();
PKCS8EncodedKeySpec privKeySpec=new PKCS8EncodedKeySpec(encKey);
prvKey=keyFactory.generatePrivate(privKeySpec);
cipher.init(Cipher.DECRYPT_MODE, prvKey);
System.out.println("cipher inited");
byte[] recoveredtext = cipher.doFinal(data.getBytes());
return new String(recoveredtext );
the src to generate key:
#!/bin/sh
if [ "$1" = "" ]; then
openssl genrsa -out temp.pem;
else
openssl genrsa -out temp.pem -rand $1 $2;
fi
openssl pkcs8 -topk8 -inform PEM -outform PEM -in temp.pem -out private.pem -v2 des3
openssl pkcs8 -topk8 -inform PEM -outform DER -in temp.pem -out private.der -nocrypt
openssl rsa -inform PEM -in temp.pem -outform PEM -out public.pem -pubout
openssl rsa -inform PEM -pubin -in public.pem -outform DER -out public.der
rm temp.pemthe script above generated keys (private.der and public.der) can really be used to do Signature.sign()
and veirfy(), which can get from file like this
/* get private key */
FileInputStream keyfis=new FileInputStream("/home/roger/ssdk/private.der");
byte[] encKey=new byte[keyfis.available()];
keyfis.read(encKey);
keyfis.close();
PKCS8EncodedKeySpec privKeySpec=new PKCS8EncodedKeySpec(encKey);
prvKey=keyFactory.generatePrivate(privKeySpec);
/* get public key */
keyfis=new FileInputStream("/home/roger/ssdk/public.der");
encKey=new byte[keyfis.available()];
keyfis.read(encKey);
keyfis.close();
X509EncodedKeySpec pubKeySpec=new X509EncodedKeySpec(encKey);
pubKey=keyFactory.generatePublic(pubKeySpec);
then be used like this:
sig.initVerify(pubKey);
sig.update(data.getBytes());
byte[] signature=HexToBytes(sigHex);
return signature==null ? false : sig.verify(signature);
of do sign()
but when used to do encrypt / decrypt, as I quoted above, it can not pass the cipher.init(...) with InValidKeyException
Can anyone throw a light ?
does it because the key is not a sunJCE provided format? (cause it is ssl)
great thanks
Maybe you are looking for
-
Problem in using Intermedia search with Oracel 9i DB on Red hat Linux
Hi, I am unable to search a particular text in a blob using Intermedia search feature.I am using Oracle 9i (9.0.2 version)mounted on Red Hat Linux OS. It works well on a Windows 2k OS. To be more precise the following query fails when I pass the INSO
-
Turn off presentation mode in ipad when connected to projector
Hi, I'd like to present the features of Neu. Annotate from my ipad. The problem is when I plug into the projector the ipad goes into presentation mode and the audience cannot see the tool bar. I need them to see the tool bar to understand the app.
-
Using Cue Points to advance to next scene
I'm pretty new to AS3. I'm a designer trying to do it myself. What I'm trying to do is use a cue point at the end of my FLV (which is loaded using ui loader in my flvSWF) to go to the next scene in my mainSWF file. here's the code I'm using in my flv
-
709/709 Source Settings and Export
I'm working with Sony RAW Lite 4k footage in Premiere, and I keep getting the default 709 LUT applied in my sequence causing unusable blown out looking footage. If I right click the clip and select Source Settings, I can select S-Log in the drop down
-
My Apps that I downloaded won't open when I click on them.
I Click on them and they just shake and won't open. I've tried turning on and off my iPod. and I Just bought a week ago and was working fine!