AES256 bit encyption key from 64 character long string

Hi,
I have Oracle 10.2 on Windows 2003. I have recently started working on a project that requires encrypting information before sending it over. I have got 64 character long string to use it as a key.
I am getting ORA-06502: PL/SQL: numeric or value error: raw variable length too long
<pre>
declare
input_string VARCHAR2 (200) := 'SomeText';
output_string VARCHAR2 (200);
encrypted_raw RAW (2000); -- stores encrypted binary text
decrypted_raw RAW (2000); -- stores decrypted binary text
key_bytes_raw RAW (32); -- stores 256-bit encryption key
encryption_type PLS_INTEGER; -- total encryption type
begin
DBMS_OUTPUT.PUT_LINE ('Original string: ' || input_string);
encryption_type := DBMS_CRYPTO.ENCRYPT_AES256 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
key_bytes_raw := UTL_I18N.STRING_TO_RAW('eiccmkjd94jfgniw03ljkdlfutcnv3209kfjd67023jlclmxzlmc9543ykflseu6', 'AL32UTF8');
encrypted_raw := DBMS_CRYPTO.ENCRYPT
src => UTL_I18N.STRING_TO_RAW (input_string, 'AL32UTF8'),
typ => encryption_type,
key => key_bytes_raw
-- The encrypted value in the encrypted_raw variable can be used here
decrypted_raw := DBMS_CRYPTO.DECRYPT
src => encrypted_raw,
typ => encryption_type,
key => key_bytes_raw
output_string := UTL_I18N.RAW_TO_CHAR (decrypted_raw, 'AL32UTF8');
DBMS_OUTPUT.PUT_LINE ('Decrypted string: ' || output_string);
end;
Please let me know hot to convert 64 character long string in to 256bit key.
Thanks
-Smith

smith_apex wrote:
My client is using Java and they are saying that they are using this key for their AES256 Encryption and working fine. I have asked them to provide me 32 bytes key as in Oracle 256bit is 32 character string.
Let me see what they have to say.
I was wondering why Java has 64 bytes for 256 AES encryption when Oracle need only 32 bytes for same encryption.I am not sure I completely understand how those built-in packages work but the doc example produces the raw key that is same in length (in terms of number of characters) as the one you are using.
Yet your UTL_I18N packaged function fails for your key but works for the documentation example.
Documentation example:
SQL> select * from v$version ;
BANNER
Oracle Database 10g Release 10.2.0.5.0 - Production
PL/SQL Release 10.2.0.5.0 - Production
CORE     10.2.0.5.0     Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
declare
   input_string       VARCHAR2 (200) := 'Secret Message';
   output_string      VARCHAR2 (200);
   encrypted_raw      RAW (2000);             -- stores encrypted binary text
   decrypted_raw      RAW (2000);             -- stores decrypted binary text
   num_key_bytes      NUMBER := 256/8;        -- key length 256 bits (32 bytes)
   key_bytes_raw      RAW (32);               -- stores 256-bit encryption key
   encryption_type    PLS_INTEGER :=          -- total encryption type
                            DBMS_CRYPTO.ENCRYPT_AES256
                          + DBMS_CRYPTO.CHAIN_CBC
                          + DBMS_CRYPTO.PAD_PKCS5;
begin
   DBMS_OUTPUT.PUT_LINE ('Original string: ' || input_string);
   DBMS_OUTPUT.PUT_LINE ('Encryption Type: ' || encryption_type);
   key_bytes_raw := DBMS_CRYPTO.RANDOMBYTES (num_key_bytes);
   DBMS_OUTPUT.PUT_LINE ('Key Bytes(RAW): ' || key_bytes_raw);
   encrypted_raw := DBMS_CRYPTO.ENCRYPT
         src => UTL_I18N.STRING_TO_RAW (input_string, 'AL32UTF8'),
         typ => encryption_type,
         key => key_bytes_raw
   DBMS_OUTPUT.PUT_LINE ('Encrypted string: ' || encrypted_raw);
    -- The encrypted value in the encrypted_raw variable can be used here
   decrypted_raw := DBMS_CRYPTO.DECRYPT
         src => encrypted_raw,
         typ => encryption_type,
         key => key_bytes_raw
   output_string := UTL_I18N.RAW_TO_CHAR (decrypted_raw, 'AL32UTF8');
   DBMS_OUTPUT.PUT_LINE ('Decrypted string: ' || output_string);
end;
32   33   34  /
Original string: Secret Message
Encryption Type: 4360
Key Bytes(RAW): 52EC66508FDF1E5DE5FD38EC2467FAA91009B738A2926AA870E142C080C72EBF
Encrypted string: 0BDDC2B94F7044700D85624297A39025
Decrypted string: Secret Message
PL/SQL procedure successfully completed.
SQL> select length('52EC66508FDF1E5DE5FD38EC2467FAA91009B738A2926AA870E142C080C72EBF') from dual ;
LENGTH('52EC66508FDF1E5DE5FD38EC2467FAA91009B738A2926AA870E142C080C72EBF')
                                             64
SQL> select dump('52EC66508FDF1E5DE5FD38EC2467FAA91009B738A2926AA870E142C080C72EBF') from dual ;
DUMP('52EC66508FDF1E5DE5FD38EC2467FAA91009B738A2926AA870E142C080C72EBF')
Typ=96 Len=64: 53,50,69,67,54,54,53,48,56,70,68,70,49,69,53,68,69,53,70,68,51,56,69,67,50,52,54,55,70,65,65,57,49,48,48,57,66,55,51,56,65,50,57,50,54,65,65,56,55,48,69,49,
52,50,67,48,56,48,67,55,50,69,66,70Your example:
declare
   input_string       VARCHAR2 (200) := 'SomeText';
   output_string      VARCHAR2 (200);
   encrypted_raw      RAW (2000);             -- stores encrypted binary text
   decrypted_raw      RAW (2000);             -- stores decrypted binary text
   key_bytes_raw      RAW (32);               -- stores 256-bit encryption key
   encryption_type    PLS_INTEGER;          -- total encryption type
begin
   DBMS_OUTPUT.PUT_LINE ('Original string: ' || input_string);
   encryption_type :=   DBMS_CRYPTO.ENCRYPT_AES256 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
   key_bytes_raw := UTL_I18N.STRING_TO_RAW('eiccmkjd94jfgniw03ljkdlfutcnv3209kfjd67023jlclmxzlmc9543ykflseu6', 'AL32UTF8');
   DBMS_OUTPUT.PUT_LINE ('Key Bytes(RAW): ' || key_bytes_raw);
   encrypted_raw := DBMS_CRYPTO.ENCRYPT
         src => UTL_I18N.STRING_TO_RAW (input_string, 'AL32UTF8'),
         typ => encryption_type,
         key => key_bytes_raw
    -- The encrypted value in the encrypted_raw variable can be used here
   decrypted_raw := DBMS_CRYPTO.DECRYPT
         src => encrypted_raw,
         typ => encryption_type,
         key => key_bytes_raw
   output_string := UTL_I18N.RAW_TO_CHAR (decrypted_raw, 'AL32UTF8');
   DBMS_OUTPUT.PUT_LINE ('Decrypted string: ' || output_string);
end;
27   28   29   30  /
Original string: SomeText
declare
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: raw variable length too long
ORA-06512: at line 12
SQL> select length('eiccmkjd94jfgniw03ljkdlfutcnv3209kfjd67023jlclmxzlmc9543ykflseu6') from dual ;
LENGTH('EICCMKJD94JFGNIW03LJKDLFUTCNV3209KFJD67023JLCLMXZLMC9543YKFLSEU6')
                                             64
SQL> select dump('eiccmkjd94jfgniw03ljkdlfutcnv3209kfjd67023jlclmxzlmc9543ykflseu6') from dual ;
DUMP('EICCMKJD94JFGNIW03LJKDLFUTCNV3209KFJD67023JLCLMXZLMC9543YKFLSEU6')
Typ=96 Len=64: 101,105,99,99,109,107,106,100,57,52,106,102,103,110,105,119,48,51,108,106,107,100,108,102,117,116,99,110,118,51,50,48,57,107,102,106,100,54,55,48,50,51,106,
108,99,108,109,120,122,108,109,99,57,53,52,51,121,107,102,108,115,101,117,54

Similar Messages

  • I have to generate a 4 char unique string from a long value

    I got a requirment
    I have to generate a 4 char unique string from a long value
    Eeach char can be any of 32 character defined has below.
    private static final char char_map[] = new char[]{'7','2','6','9','5','3','4','8','X','M','G','D','A','E','B','F','C','Q','J','Y','H','U','W','V','S','K','R','L','N','P','Z','T'};
    So for 4 char string the possible combination can be 32 * 32 * 32 * 32 = 1048576
    If any one passes a long value between 0 - 1048576 , it should generate a unique 4 char string.
    Any one with idea will be a great help.

    Well, a long is 64 bits. A char is 16 bits. Once you determine how you want to map the long's bits to your char bits, go google for "java bitwise operators".

  • Extract multiple data from long string

    I am working in Crystal Reports XI looking at an SQL database. How can I pick up several different data bits from a realy long string? Each element I want is preceded by "Old Value =" or "New Value =". The problem is that there are up to 4 different sets of these "Old Value =", "New Value =" so I can only get the first set if I use "InStr" to find "Old Value =" or "New Value =".
    Since they are preceded by unique headings like "RuntimeMinutes", I thought I could use "InStr" to find that "RuntimeMinutes" or whichever and then use that value as the location number nested in another "InStr" to find "New Value =" and nest it all in a "Mid" expression. But however I did it I got an error highlighting that "InStr" nested in "InStr" saying it was not an integer or the value was less than 1.
    Any ideas?

    The way that I'd deal with this is by creating formula fields for each value that you want to extract.  In the sample below, I'm assuming your string looks something like this:
    RuntimeMinutes OldValue=123 NewValue=234 DbReads OldValue=12345 NewValue=34567
    The formula for {@Runtime Minutes Old Value} would then look like (basic syntax):
    dim pos as number
    ' Find where RuntimeMunutes old and new values start:
    pos = InStr({really long string}, "RuntimeMinutes")
    ' Find first OldValue after RuntimeMinutes:
    pos = InStr(pos + 14, {really long string}, "OldValue")  ' 14 = Len("RuntimeMinutes")
    ' Pull out the value:
    formula = val(mid({really long string}, pos + 9,
                        Instr(pos + 9, {really long string}, " ") - pos - 9)) ' 9=Len("OldValue=")
    And do the same for all of the other values you need. 
    HTH,
    Carl

  • Removing Null values from character string

    Hi All,
    Can i remove NULL values (hexadecimal - 0000) from character string. I am uploading a file from presentation layer (shared server) and getting NULL values in many fields which i want to remove.
    please assist.
    Thanks for you help..
    Regards,
    Mohaiyuddin

    Hi,
    Most likely, nobody needed it, but if anybody in future will need the solution for related problem  - here's solution:
    data: lv_nullchar type xstring value '0'.
    shift lv_xstring right deleting trailing lv_nullchar in byte mode.
    shift lv_xstring left deleting leading lv_nullchar in byte mode.
    This hack deleting null chars in lv_xstring at end file and at begining of file. Works perfect for me, where i also worked with files.

  • Conversion failed when converting date and/or time from character string

    Hi experts,
    I'm trying running a query in Microsoft Query but it gives the following error message:
    "conversion failed when converting date and/or time from character string"
    when asks me the data I'm inserting 31-01-2014
    i've copy the query form the forum:
    SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
         CASE  WHEN T0.TransType=13 THEN 'Invoice'
              WHEN T0.TransType=14 THEN 'Credit Note'
              WHEN T0.TransType=30 THEN 'Journal'
              WHEN T0.TransType=24 THEN 'Receipt'
              END AS 'Document Type',
         T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
    FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
    WHERE (T0.MthDate IS NULL OR T0.MthDate > ?) AND T0.RefDate <= ? AND T1.CardType = 'C'
    ORDER BY T1.CardCode, T0.DueDate, T0.Ref1

    Hi,
    The above error appears due to date format is differnt from SAP query generator and SQL server.
    So you need convert all date in above query to SQL server required format.
    Try to convert..let me know if not possible.
    Thanks & Regards,
    Nagarajan

  • I can no longer turn on or off 32 bit to 64 from the info window.

    I can no longer turn on or off 32 bit to 64 from the info window. I have done a total reinstall with system 10.6 and Logic with no results. I was running Lion but it would allow me to run my Tascam FW-1884. I need to switch back to 32bit on Logic to enable new plugins on my UAD-2 Card. My Question is was the 32bit to 64 bit switch available in version 10.6 or was it introduced in 10.68?

    Turn on the option see by others. And it should be work fine.

  • Error "Conversion failed when converting date and/or time from character string" to execute one query in sql 2008 r2, run ok in 2005.

    I have  a table-valued function that run in sql 2005 and when try to execute in sql 2008 r2, return the next "Conversion failed when converting date and/or time from character string".
    USE [Runtime]
    GO
    /****** Object:  UserDefinedFunction [dbo].[f_Pinto_Graf_P_Opt]    Script Date: 06/11/2013 08:47:47 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE   FUNCTION [dbo].[f_Pinto_Graf_P_Opt] (@fechaInicio datetime, @fechaFin datetime)  
    -- Declaramos la tabla "@Produc_Opt" que será devuelta por la funcion
    RETURNS @Produc_Opt table ( Hora datetime,NSACOS int, NSACOS_opt int)
    AS  
    BEGIN 
    -- Crea el Cursor
    DECLARE cursorHora CURSOR
    READ_ONLY
    FOR SELECT DateTime, Value FROM f_PP_Graficas ('Pinto_CON_SACOS',@fechaInicio, @fechaFin,'Pinto_PRODUCTO')
    -- Declaracion de variables locales
    DECLARE @produc_opt_hora int
    DECLARE @produc_opt_parc int
    DECLARE @nsacos int
    DECLARE @time_parc datetime
    -- Inicializamos VARIABLES
    SET @produc_opt_hora = (SELECT * FROM f_Valor (@fechaFin,'Pinto_PRODUC_OPT'))
    -- Abre y se crea el conjunto del cursor
    OPEN cursorHora
    -- Comenzamos los calculos 
    FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
    /************  BUCLE WHILE QUE SE VA A MOVER A TRAVES DEL CURSOR  ************/
    WHILE (@@fetch_status <> -1)
    BEGIN
    IF (@@fetch_status = -2)
    BEGIN
    -- Terminamos la ejecucion 
    BREAK
    END
    -- REALIZAMOS CÁLCULOS
    SET @produc_opt_parc = (SELECT dbo.f_P_Opt_Parc (@fechaInicio,@time_parc,@produc_opt_hora))
    -- INSERTAMOS VALORES EN LA TABLA
    INSERT @Produc_Opt VALUES (@time_parc,@nsacos, @produc_opt_parc)
    -- Avanzamos el cursor
    FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
    END
    /************  FIN DEL BUCLE QUE SE MUEVE A TRAVES DEL CURSOR  ***************/
    -- Cerramos el cursor
    CLOSE cursorHora
    -- Liberamos  los cursores
    DEALLOCATE cursorHora
    RETURN 
    END

    You can search the forums for that error message and find previous discussions - they all boil down to the same problem.  Somewhere in your query that calls this function, the code invoked implicitly converts from string to date/datetime.  In general,
    this works in any version of sql server if the runtime settings are correct for the format of the string data.  The fact that it works in one server and not in another server suggests that the query executes with different settings - and I'll assume for
    the moment that the format of the data involved in this conversion is consistent within the database/resultset and consistent between the 2 servers. 
    I suggest you read Tibor's guide to the datetime datatype (via the link to his site below) first - then go find the actual code that performs this conversion.  It may not be in the function you posted, since that function also executes other functions. 
    You also did not post the query that calls this function, so this function may not, in fact, be the source of the problem at all. 
    Tibor's site

  • SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.  'Received Alerts' (OAIB)

    SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.  'Received Alerts' (OAIB)
    SELECT    
    CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
    WHEN T0.DocStatus = 'C' THEN 'CLOSED'  END  AS 'Document Status',
    T0.DocDate AS 'Posting Date',
    T0.DocNum AS 'Doc.No',
    T0.NumAtCard,
    T0.TransId AS 'Trans. No.',
    T0.Comments AS 'Remarks',
    T0.CardCode AS 'Offset Acct',
    T0.CardName AS 'Offset Acct Name',
    sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
    T3.DueDate AS 'Cheque Date',
    T3.CheckSum AS 'Amount'
    FROM         ODPO AS T0 LEFT OUTER JOIN
                          VPM2 AS T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
         OVPM AS T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
                          VPM1 AS T3 ON T2.DocEntry = T3.DocNum
    where T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

    Hi,
    Try this:
    SELECT   
    CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
    WHEN T0.DocStatus = 'C' THEN 'CLOSED'  END  AS 'Document Status',
    T0.DocDate AS 'Posting Date',
    T0.DocNum AS 'Doc.No',
    T0.NumAtCard,
    T0.TransId AS 'Trans. No.',
    T0.Comments AS 'Remarks',
    T0.CardCode AS 'Offset Acct',
    T0.CardName AS 'Offset Acct Name',
    sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
    T3.DueDate AS 'Cheque Date',
    T3.CheckSum AS 'Amount'
    FROM         ODPO  T0 LEFT OUTER JOIN
                          VPM2  T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry
    LEFT OUTER JOIN
         OVPM  T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
                          VPM1  T3 ON T2.DocEntry = T3.DocNum
    where T0.DocDate >= '[%0]' and T0.DocDate <='[%1]'
    group by T0.DocStatus,T0.DocDate ,
    T0.DocNum ,
    T0.NumAtCard,
    T0.TransId ,
    T0.Comments ,
    T0.CardCode,
    T0.CardName ,
    T0.WTSum ,
    T3.DueDate ,
    T3.CheckSum
    Thanks & Regards,
    Nagarajan

  • Passing a long string from Vb to stored proc

    Hi,
    I am passing a long string from Vb to this stored proc ..
    defn:
    Create Or Replace Procedure saveTaxFormInDB(intFormUID IN number,
    intCLUID IN number,
    PDFdata IN varchar2,
    Status IN OUT Varchar2) AS
    Problem lies with the string pdfdata. I am sending it from VB as:
    Set cmdParamStr = cmdAdoCmd.CreateParameter("Data", adVarChar,
    adParamInput, 32767, strData)
    I have checked the parameters in VB while sending and I have the
    correct string argument to be passed to "PDFData", But i am not
    sure if it is getting the value correctly.
    Because I know that the code is raising exception while
    accessing PDFData. (eg. in places like insert ..(pdfdata) and
    length(pdfdata)...)
    Please advise how i can solve this problem.
    Please Note that the string is not VERY large. I do not need to
    use LOBS in any way. the string is definitely within the limits
    of varchar2(which i think is 4000 chars.. correct me if i am
    wrong).
    Many thanks

    what is the backend MS SQl server or Oracle.??
    If it is MS SQLSERVER, then
    1.Create a SqlCommand object with the parameters as the name of the stored procedure that is to be executed and the connection object con to which the command is to be sent for execution.
    SqlCommand command = new SqlCommand("Name of StoredProcedure",con);
    2.Change the command objects CommandType property to stored procedure.
    command.CommandType = CommandType.StoredProcedure;
    3.Add the parameters to the command object using the Parameters collection and the SqlParameter class.
    command.Parameters.Add(new SqlParameter("@parametername",SqlDbType.Int,0,"Filedname"));
    4.Specify the values of the parameters using the Value property of the parameters
    command.Parameters[0].Value=4;
    command.Parameters[1].Value="ABC";
    If it is oracle,
    OracleConnection con = new OracleConnection("uid=;pwd=");
    try
    con.Open();
    OracleCommand spcmd = new OracleCommand("Name of StoredProcedure");
    spcmd.CommandType = CommandType.StoredProcedure;
    spcmd.Connection = con;
    spcmd.Parameters.Add("empid", OracleType.Number, 5).Value = txtEmpid.Text;
    spcmd.Parameters.Add("sal", OracleType.Number, 5).Value = txtSal.Text;
    spcmd.ExecuteNonQuery();
    }

  • Moving bits from a long to a int

    How do u remove bits from a long and then put then into a int???
    thanks,
    kelvin

    int i = (int)meLong;?

  • How can I copy a long string of texts from my iPhone 4s to a word document?

    I need to copy a long string of texts to a word document on my PC.

    One method would be to use 3rd party software. The following is one example but there may be better/cheaper or even free options: http://www.wideanglesoftware.com/touchcopy/

  • Passing long string to shell script from java

    I am trying to passa a long string to a shell process through java,
    call is like
    Runtime rtime = Runtime.getRuntime();
    String callAndArgs[] = {"/apps/jetty4/jstest/jstest.sh",jarCo,queue,text};
    Process child = rtime.exec(callAndArgs);
    here the string text is :
    |HEADER|JAR933|[email protected]|290001|OL0006528|WIN4015444|SHAFT_FORGING|1.0|Baan EDM|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    |290001|WIN4015444|00||||2|SHAFT FORGING|9|AXELSMIDE|3|ACHSE SCHMIEDEST�CK|4|ARBRE FORG�|f|AKSELITAOS|||||||||||||||||||||||No||Approved|41.0|Mechanic|Yes|pc||WIN4015444|EL20|Purchased|Metric||0|20051120|||||Released||||||||||||||||No||||||||||||||||||||||||||||||||
    Now i use this string in shell script to pass as an argument to other class. But the string gets truncated.
    How do i solve this?

    It appears that your os is truncating the data - Java's not involved.
    Maybe write the data to a file and then read it into the external program some way.

  • Removing extra spaces from a long document

    Hello
    I have seen a number of find/change and GREP formulas to do similar things. I have NO scripting or coding experience and have labored to understand GREP.
    So I am a little afraid to use it as I don't know what all the modifiers refer to (I do have a printout of some neat GREP cheatsheets like Mike Witherell's that I can absorb until I obtain a good reference )
    I need something I can copy and paste into either find/change or GREP dialog that will do the following in less than 12 steps (hopefully) without doing something catastrophic like removing all of my paragraph marks (which I almost did using someones GREP expression)
    No spaces before any comma, period, exclamation mark, question mark, colon, semicolon
    One space only after any of those
    One Space before any opening parenthesis and one space after the closing parenthesis
    No space after the opening parenthesis or before the closing parenthesis
    Remove any double or extra spaces ( en, em etc.)
    Remove any commas before parentheses
    Remove any spaces after a paragraph mark
    I think that's it
    I did find this one recently (Maybe Jongware?)
    [~m~>~f~|~S~s<~/~,~3~4%]{2
    Which from my dim understanding addresses em, en, flush and hair space ,  nonbreaking space ,figure space,third space--not sure of the rest. Really this is way over my head.
    I know this will be a piece of cake for you guys
    Thanks

A: Removing extra spaces from a long document

Peter is too modest, he's doing just great.
No space BEFORE-One Space after ---period,semicolon,colon, exclamation, question mark,CLOSING Parenth,Bracket,Brace, single & Dbl. quotation marks
Find (\s)([.,;:!\)\]\}~}~]])
Replace with $2
No space AFTER-One Space Before----OPENING bracket,brace,parenthesis,Dbl & single quotes
Find ([\[\{\(~{~[])(\s)
Replace with $1
These remove the space before/after but do not automatically add a space after/before.
In the first case, you could add a space right after the '$2' in the Replace With string, but it already may have a space, in which case you suddenly have two. One alternative is to optionally remove it with the Find string (add it as an optional match) and always add it with the Replace string, but remember that this string will only be found if there is a space preceding it. That way you'd only check the space after in cases where there was a bad space before.
So I propose you add another two find/changes to add the space, only when necessary.
One Space After: find
([.,;:!\)\]\}~}~]])(?!\s)
replace:
$0 [followed by one single space]
One Space Before: find
(?<!\s)([\[\{\(~{~[])
replace:
[one single space] $0
Color-coding with my WhatTheGrep might make it just a tad clearer what's going on in that jumble of codes:
(1 [ .,;:! \) \] \} ~} ~] ] 1) (?!! \s !)
and
(?<!<! \s <!) (1 [ \[ \{ \( ~{ ~[ ] 1)
(Orange is lookahead/lookbehind, blue is a regular escaped character, pink is an InDesign special character, green is normal grouping parentheses, and lavender is a character group.)

Peter is too modest, he's doing just great.
No space BEFORE-One Space after ---period,semicolon,colon, exclamation, question mark,CLOSING Parenth,Bracket,Brace, single & Dbl. quotation marks
Find (\s)([.,;:!\)\]\}~}~]])
Replace with $2
No space AFTER-One Space Before----OPENING bracket,brace,parenthesis,Dbl & single quotes
Find ([\[\{\(~{~[])(\s)
Replace with $1
These remove the space before/after but do not automatically add a space after/before.
In the first case, you could add a space right after the '$2' in the Replace With string, but it already may have a space, in which case you suddenly have two. One alternative is to optionally remove it with the Find string (add it as an optional match) and always add it with the Replace string, but remember that this string will only be found if there is a space preceding it. That way you'd only check the space after in cases where there was a bad space before.
So I propose you add another two find/changes to add the space, only when necessary.
One Space After: find
([.,;:!\)\]\}~}~]])(?!\s)
replace:
$0 [followed by one single space]
One Space Before: find
(?<!\s)([\[\{\(~{~[])
replace:
[one single space] $0
Color-coding with my WhatTheGrep might make it just a tad clearer what's going on in that jumble of codes:
(1 [ .,;:! \) \] \} ~} ~] ] 1) (?!! \s !)
and
(?<!<! \s <!) (1 [ \[ \{ \( ~{ ~[ ] 1)
(Orange is lookahead/lookbehind, blue is a regular escaped character, pink is an InDesign special character, green is normal grouping parentheses, and lavender is a character group.)

  • When I forward an e-mail, I get a long string of gobblygook that goes with it and I cannot figure out how to eliminate it without having to delete it every time

    When I forward an e-mail, I get a long string of gobblygook that goes with it and I cannot figure out how to eliminate it without having to delete it every time I forward an e-mail. The following is only part of the string that I am talking about. How can I eliminate this from the e-mail?
    Here is part of an excerpt from one of the strings:
    From: - Mon Aug 19 18:12:47 2013
    X-Account-Key: account1
    X-UIDL: 065B31352CC6B3C0789DEA7954395B55
    X-Mozilla-Status: 0001
    X-Mozilla-Status2: 00000000
    X-Mozilla-Keys:
    Return-Path: <[email protected]>
    Received: from hrndva-mxlb.mail.rr.com ([10.128.255.126]) by hrndva-imta07.mail.rr.com with ESMTP id <20130819211326470.DBUO12525@hrndva-X-Roving-StreamId: 0

    Sorry, Firefox doesn't do email, it's strictly a web browser.
    If you are using Firefox to access your mail, you are using "web-mail". You need to seek support from your service provider or a forum for that service.
    If your problem is with Mozilla Thunderbird, see this forum for support.
    [https://support.mozillamessaging.com/en-US/home] <br />
    or this one <br />
    [http://forums.mozillazine.org/viewforum.php?f=39]

  • Read byte from a long

    Hi,
    How can I read bytes from a long. i..e read one byte by one byte from long.
    Naman Patel

    ok here is my problem how do i ignore the sign byte i.e please check this code
    long nr=1345345333L, add=7, nr2=0x12345671L;
              long tmp;
              long[] result = new long[2];
              char[] pwd = password.toCharArray();
              for (int pCount = 0; pCount < pwd.length; pCount++){
                   if (pwd[pCount] == ' ' || pwd[pCount] == '\t')
                        continue;
                   tmp= (long) pwd[pCount];
                   nr^= (((nr & 63)+add)*tmp)+ (nr << 8);
                   nr2+=(nr2 << 8) ^ nr;
                   add+=tmp;
              result[0]=nr & (((long) 1L << 31) -1L); /* Don't use sign bit (str2int) */;
              result[1]=nr2 & (((long) 1L << 31) -1L);
              int i = 0;
              long x = result[0];
              byte b[] = longToBytes(x);
              String str = "";
              i = 0;
              while(i < 4){
                   if(b[i] == 0x00) {
                        System.out.println("byte is 0x00");
                        str += "00";
                   else {
                        if(b[i] <= 0x0f && b[i] >= 0) {
                             System.out.println("byte is 0x0f" + b);
                             str += "0";
                        break;
                   i++;
              i = 0;
              str += Long.toHexString(result[0]);
              x = result[1];
              b = longToBytes(x);
              while(i < 4){
                   if(b[i] == 0x00) {
                        System.out.println("byte is 0x00");
                        str += "00";
                   else {
                        if(b[i] <= 0x0f && b[i] >= 0) {
                             System.out.println("byte is 0x0f");
                             str += "0";
                        break;
                   i++;
              str += Long.toHexString(result[1]);

  • Maybe you are looking for

    • Blocking RdA creation from Sales Order Schedule Line

      Hi Gurus, please do you know if there is a way to block the RdA creation from Sales Order schedule line, for TAS item category? I tried with Header Delivery block without quantity confirmation but even if quantity on schedule lines are not confirmed,

    • Short Dump  while scrolling on the ALV (GETWA_NOT_ASSIGNED)

      Hi All, I have an interactive ALV list, After the user double click on the list line item, the list control goes to top of the list. When i want to scroll  for further interaction, I am getting  a Short dump  GETWA_NOT_ASSIGNED. Please advice Solomon

    • How do I order more than one book at a time?

      I created 10 photo books I would like to order, but when I go to place my order I can only place one book at a time.  I do not want to place 10 different orders.  How do I order more than one book at a time?

    • Problems with blog template

      I'm having two problems with the blog template. First, I wanted to add some images to a blog entry in addition to the main photo at the top of the page. I had wanted these to appear below the main text box. So I selected several pictures in iPhoto an

    • Icon association not working

      I set my .avi files to open with QT instead of VLC (and applyed to all files) but instead of getting files with QT icon, now I have files with a blank or grey (with small green part) Icons, like those that usually are associated with non mac files. T