Limit encrypted string length to 20 characters

Hi,
How do I limit encrypted string to 20 characters or 'x' number of characters?
e.g. encrypting "hello" might produce the following out put -> "F1==iI09Poiui7@=1kjuyo" but if I wanted to limit the length 20 characters or less. Is there any
possibility of doing this? If yes, Can someone help me out?
Thanks
Mathew

mathewrond wrote:
There are no constraints on input characters.
I need to encrypt since the input data is confidential.
The resultant encrypted data length can be equal or less than n* 2. This is because we have defined varchar(n*2) as the maximum length for a column in database, so we cannot have encrypted data beyond the length specified in database.You seem to be confusing characters and bytes.
A String of length 'm' is transformed to bytes of length >= 'm' depending on the language and encoding scheme. Let us assume one uses utf-8 encoding then for western languages the length will usually be 'm' or just a bit greater than 'm'. For eastern languages this could be as much as '3*m' bytes but usually closer to '2*m' bytes. So, let as take the multiplier to be 'k' .
Encrypting using a block cipher with a block length 'N' bytes then using PKCS5 padding one will end up with '(k*m/N +1)*N' bytes. If you then Base64 encode these encrypted bytes to convert to characters you will extend the length by a factor of about 4/3 ending up with '(((k*m/N +1)*N + 2)/3)*4' ASCII characters.
Encrypting using a stream cipher you will end up with 'k*m' bytes which after Base64 encoding will become '((k*m+2)/3)*4' ASCII characters. BUT, of course you will need a different key for each value you encrypt. This makes it much more difficult to use and cannot be recommended.
Since you have decided on using a varchar to hold the encrypted data you have to use Base64 encoding (or something similar). If you had chosen varbinary then you could have saved yourself the factor of 4/3 .
Note - all division is assumed to be integer division. e.g. 7/3 == 2

Similar Messages

  • Limit String Length

    Tried searching first... But couldn't seem to find answer...
    I need to limit a string length...
    So perhaps the initial string is: "New York is North of
    Miami"
    Which is 26 characters...
    And I want to limit the returned result to 15 characters to
    get "New York is Nor"
    How would I do this...
    I can count len etc but haven't figured out this one...
    Thanx...

    Not sure is this what u r looking for. You can use Left
    function
    Left(string, count)
    ex.
    <cfset sTest = "New York is North of Miami">
    <cfset sTest2 = Left(#sTest1#,15)
    now sTest = "New York is Nor"

  • Limit string-length in Reporting Data Source

    Hello,
    we want to report some attributes to the BI. For this we use the standard reporting activity in the BPM. After we done a lot of configuration on the CE and the BI we achieved to connect the two systems. All attributes are passed correctly to the BI and now we have a problem with the string-length we pass to the BI. The string-length they get from the CE is 512 but the BI can only handle strings with a 60-length. Is it possible to limit the length of a string in the BPM or the CE?
    Manuel

    Hello Jun,
    I have created reporting data source in my BPM where my parameter defined is of type "STRING'.
    This data source is accessed by BW system for reporting purpose where they get an error as below -
    "STRING/XTRING types used Not supported by currently selected access method UDCGEN; cannot use this method"
    Looks like BW does not support string type, how can we make this datatype compatible?
    Please share if you have any idea.
    Thanks,
    Priya

  • NI-Communicator truncates string length

    When using NI-Communicator to send commands to a particular instrument, we have discovered that the NI-Communicator is limiting the length of the string sent to the instrument to 99 characters. This can be observed by using NI-Spy. The same NI-488.2 drivers can be used from another custom program to send much longer strings.
    The user interface to NI-Communicator should be fixed to limit input strings to the same length or this limitation should be fixed.

    Hello Marv,
    The NI-488.2 Communicator is primarily for troubleshooting purposes, which is why it only shows a limited number of characters. GPIB communication is usually done through a program because the responses also need to be parsed and processed. I will, however, submit your request to R&D to have that length re-evaluated.
    Ray K
    NI Applications Engineer

  • AES Encryption - Encrypted value lengths

    HI all -
    I am attempting to use CF 8's AES encryption feature, and
    have not found a critical piece of info in the docs to enable me to
    progress.
    I am using the function to encrypt a password that can be
    from 6 to 16 characters long, which will be stored in a database. I
    am using generateSecretKey("AES"), and that gives me a 24 character
    key that I'm storing for future decryption use. I find that when I
    use the key to encrypt a 6 character password the resulting
    encrypted string is 32 characters long, but when I encrypt a 16
    character password I get a 64 character encrypted string. This is
    the case whether I specify "HEX" or "UU" as the encoding.
    Without knowing how the length of the resulting encoded
    string is determined, I cannot know how large to make my database
    column. (MySQL's AES encryption gives the formula 16 ×
    (trunc(string_length / 16) + 1) to arrive at the resulting string's
    length, but that formula doesn't yield the results I'm seeing in
    CFMX). Can anyone point me to a doc, or explain to me how to
    determine the column length for storing the resulting encrypted
    value?

    No. Only things like key, encoding and string size should
    matter. If the encoding is "hex", 1-15 characters should produce
    size 32, 16-31 characters should produce 64, etcetera. Unless space
    is at a premium, you could always increase the field size if that
    makes you feel more comfortable.
    Well, the results are dictated by the AES standard and basic
    string encoding rules, not CF. I highly doubt either one is going
    to change any time soon ;-) I agree documentation is good. However,
    unlike aes_encrypt, the encrypt function supports many different
    algorithms. Most of which have a distinct set of rules. So it would
    probably be difficult to provide accurate information about all of
    them. Especially as the specifications for each one alone probably
    spans volumes ;-)

  • Restrict the input string length

    Hi, how do I restrict the input string length in a JTextField. Suppose if I want my text field to accept only 4 characters, the fifth character I try to enter shouldn't be accepted in the field.
    Thanks,
    Kalyan.

    This is for 6 characters limit
    //create a JTextField that is six characters long
    JTextField textField = new JTextField(new FixedNumericDocument(5,true),"", 6);
    Here boolean true means only numeric. set to false to take in alphanumeric.
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;
    public class FixedNumericDocument extends PlainDocument {
    private int maxLength = 9999;
    private boolean numericOnly;
    public FixedNumericDocument(int maxLength, boolean numericOnly) {
    super();
    this.maxLength = maxLength;
    this.numericOnly = numericOnly;
    //this is where we'll control all input to our document.
    //If the text that is being entered passes our criteria, then we'll just call
    //super.insertString(...)
    public void insertString(int offset, String str, AttributeSet attr) throws BadLocationException {
    if (getLength() + str.length() > maxLength) {
    return;
    else {
    try {
    if (numericOnly) {
    Integer.parseInt(str);
    //if we get here then str contains only numbers
    //so that it can be inserted
    super.insertString(offset, str, attr);
    catch(NumberFormatException exp) {
    return;
    return;

  • Unencrypted password length vs. Encrypted password length

    Hi,
    Can anybody share the formula to get the resulting String length of an encrypted password.
    For example: how long will the encrypted String be given a 5 letter unencrypted password?
    Will this change across different algo? e.g. MD5/SHA1 and two way hash...
    Need this to make sure the database field is of the correct size for the encrypted password...
    based on prior experience, the resulting encrypted String is always longer than the inputted password but I cannot find a reference stating the formula...
    Thanks in advance

    A few things to keep in mind:
    1) Do not think of Strings when you are using cryptography. Always think in byte buffers (byte[]). Strings can perform implicit character conversions that will mess up your encryption (and decryption).
    2) Do you really need to encrypt the password? Most password files are simply hashed. You can go one step better by adding 'salt' prior to taking the hash.
    As for calculating lengths, it depends on the algorithm. But in all likelihood, rather than trying to calculate the exact, expected size, just make the database field larger. (I know, sloppy programming, but space is cheap, especially for storing a password).
    - Saish
    "My karma ran over your dogma." - Anon

  • Encrypted string is too long

    hi,
    I have to en/decrypt a lot of text for storing in a database. all crypt.classes I found put out an encrypted string which is much longer then the original string. that may be good for passwords, but not for real text and a limited amount of chars in the database-field.
    does someone know a class for en/decryption that holds the initial number of chars (more or less)?
    thank you
    gammloop

    How strong of encryption do you need? If you just want to make sure that some data isn't read by admins then use a simple substitution or XOR scheme, then your ciphertext length will equal your plaintext length. If you need something strong then you're going to have to deal with larger text lengths. I think block ciphers will just pad to some multiple of the block length.
    Good Luck
    Lee

  • Using "string-length" in STANDARD receiver determ xpath rule in PI 7.11

    Hi
    I have a situation, where I need to call one system, if the businesspartner value is 6 characters long and call an other system, if the length is different from 6 characters.
    I am trying to use the standard receiver determination by entering this rule, but it does not work:
    (string-length(/p1:ValidateUserRequest/Businesspartner)) = 6          ->   system1
    (string-length(/p1:ValidateUserRequest/Businesspartner)) not=  6   ->   system2
    Is there no way of sprucing up the standard xpath expression in the way I try?
    What alternatives do I have?
    Mikael

    Hi,
    Please try giving the XPath expression as given below:
    /p1:ValidateUserRequest [string-length(Businesspartner) = 6]  system1
    /p1:ValidateUserRequest [string-length(Businesspartner) != 6] system 2
    Please use square brackets before "string" and after "6"...its not getting displayed in my reply...:-(
    Rgds,
    Lekshmi.
    Edited by: Lekshmi N on Jan 6, 2010 12:29 PM

  • How to increase the string length of an uploaded file

    Hi,
    i use a abap webser where i've uploaded some JAR files into the mime repository.
    Unfortunately the string length is limited by 40 characters and so longer file names are cut.
    How can I increase the default string length? Does somebody know a workaround?
    Thanks.
    Edited by: Martin Gardyan on Oct 22, 2008 9:48 AM

    what i guess copying those jars should not create this problem.U just try in db using
    "ALTER TABLE <table_name> MODIFY <column_name> VARCHAR2(<new, larger length>)"
    may be it works.
    Regards,
    Anu

  • Execute a DML query its length exceeds 4000 characters with execute immediate statement.

    I want to execute a DML query with execute immediate statement. That DML query length exceeds 4000 characters. This query has Xquery related conditions, i can not split the query. when i tried execute it is giving "string literal too long".  I tried with DBMS_SQL.Parse() and DBMS_SQL.Execute also, but it is giving same error. I have to execute this DML query inside a Procedure. Please help me to resolve this. We are using oracle 10g version
    Thanks & Regards,
    K.Kedarnadh

    Actually Query is a dynamic query. Query length will exceeds if the no of domains\domain values \products exceeds. Any way Below one is current dynamic query, which is generated within procedure
    SELECT
      IVT.ID_IVT
        ,IVT.ID_INS_IVT
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//productName/text()') AS PRODUCTNAME
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//elementName/text()') AS INSTANCENAME
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//elementInternalName/text()') AS INTERNALNAME
        ,CTG.NAME_CTG
        ,CTR.NAME_CTR
        ,MDL.NAME_MDL
      ,IVT.REEDIT_FLAG_IVT
        FROM  VARIATION_IVT IVT INNER JOIN CATEGORY_CTG CTG ON CTG.ID_CTG=IVT.ID_CTG_IVT
      AND IVT.STATUS_IVT='Active' AND IVT.DELETE_FLAG_IVT=0 AND IVT.ID_PRJ_IVT=1
      AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="Jurisdictions" and (domainValue="Delhi" or domainValue="Bangladesh" or domainValue="Mumbai" or domainValue="India" or domainValue="Pakistan" or domainValue="Nepal" or domainValue="Maldives" or domainValue="Kolkata" or domainValue="Bhutan" or domainValue="Chennai" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="Channels" and (domainValue="Agents" or domainValue="SBI" or domainValue="Maruti" or domainValue="Direct" or domainValue="CitiFinancial" or domainValue="SCB" or domainValue="BankAssurance" or domainValue="CitiBank" or domainValue="Employees" or domainValue="GE" or domainValue="Brokers" or domainValue="Telemarketing" or domainValue="Agency" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="ModeofDelivery" and (domainValue="Walkin" or domainValue="Internet" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//context[(productName="ALL" or productName="A009" or productName="A010" or productName="A046" or productName="AccidentShieldClassic" or productName="AccidentShieldOnline" or productName="AM01" or productName="AM02" or productName="AME_Cancellation" or productName="ARHG" or productName="ARPA" or productName="B003" or productName="B004" or productName="B007" or productName="B008" or productName="B009" or productName="B010" or productName="B012" or productName="B013" or productName="B015" or productName="B016" or productName="B017" or productName="BC04_PA" or productName="BC06_FDP" or productName="BC06_PA" or productName="BC09" or productName="BC10" or productName="BC12" or productName="BC13" or productName="BF03" or productName="BS01" or productName="BS02" or productName="C017" or productName="C035" or productName="C036" or productName="C037" or productName="C038" or productName="C040" or productName="C041" or productName="C041Gold" or productName="C041New" or productName="C045HomeContents" or productName="C048" or productName="C049" or productName="C054" or productName="C057" or productName="C060Building" or productName="C060Contents" or productName="C060FDP" or productName="C061Building" or productName="C061Contents" or productName="C062" or productName="C063" or productName="C067" or productName="C070" or productName="C072" or productName="C074" or productName="C077" or productName="C081" or productName="C082" or productName="C087" or productName="C088" or productName="CITIFOREVER" or productName="CITISECURE" or productName="CITICHILDPLAN" or productName="D001" or productName="DB01" or productName="DD01" or productName="DD02" or productName="DD03" or productName="DD04" or productName="DD09" or productName="DD10" or productName="E005" or productName="E011" or productName="E016" or productName="E020" or productName="E030" or productName="E034" or productName="E040" or productName="E041" or productName="E045HCP" or productName="E045HSP" or productName="E049" or productName="E049New" or productName="E052" or productName="E053" or productName="E054FDP" or productName="E055" or productName="E056" or productName="E057" or productName="E058" or productName="E061" or productName="E061BATCH" or productName="E062" or productName="E063" or productName="E064HCP" or productName="E064HSP" or productName="E066" or productName="E069" or productName="E073" or productName="E075" or productName="E076" or productName="E088" or productName="E090" or productName="E093A" or productName="E093B" or productName="E095" or productName="E099A" or productName="E099B" or productName="E106" or productName="E107" or productName="E110" or productName="E112" or productName="E114" or productName="E115" or productName="E116" or productName="F001" or productName="FamilyHealthInsurance" or productName="FamilyHospitalBenefits" or productName="FamilyHospitalisationCoverBenefit" or productName="G001" or productName="G002" or productName="HealthShieldOnline" or productName="Health_B005" or productName="Health_S057" or productName="HealthSheild" or productName="HealthWalkin" or productName="HomeContentOnline" or productName="HomeShieldOnline" or productName="HomeShieldWalkin" or productName="HospitalCashOnline" or productName="J001" or productName="J008" or productName="K001" or productName="KV02" or productName="LC03" or productName="ML01" or productName="MP02" or productName="MP03" or productName="MR01" or productName="O005" or productName="PO01" or productName="PO02" or productName="PO03" or productName="PO04" or productName="PO05" or productName="PO06" or productName="RR02" or productName="RR03" or productName="RR04" or productName="S006" or productName="S033" or productName="S049" or productName="S051" or productName="S054" or productName="S057" or productName="S060" or productName="S061" or productName="S065" or productName="S065TM" or productName="S068" or productName="S076" or productName="S077" or productName="S079" or productName="S080" or productName="S081" or productName="S084" or productName="S085" or productName="S086" or productName="S087" or productName="S088" or productName="S091" or productName="S092" or productName="S093" or productName="S094" or productName="S095" or productName="S097" or productName="S098" or productName="S099" or productName="S100" or productName="S101" or productName="S102" or productName="S103" or productName="S104" or productName="S106" or productName="S107" or productName="S108" or productName="S109" or productName="S110" or productName="S111" or productName="S113" or productName="SCBNAC" or productName="SF02" or productName="SS01" or productName="SS02" or productName="SUNFHM" or productName="SurgicalShield" or productName="TD01" or productName="TD02" or productName="TP01" or productName="U002Building" or productName="U002Contents" or productName="U004Building" or productName="U007" or productName="U009" or productName="U013" or productName="U014" or productName="U015" or productName="U016" or productName="V001" or productName="V002" or productName="V005" or productName="V006" or productName="V008" or productName="W008" or productName="W020" or productName="W021" or productName="W022" or productName="W023" or productName="W024" or productName="W026" or productName="W027" or productName="W028" or productName="W029" or productName="W105" or productName="W106" or productName="WI01" or productName="WI02" or productName="WI03" or productName="WI07" or productName="WI08" or productName="WI09" or productName="WI10" or productName="WI11" or productName="WI12" or productName="WI13" or productName="WI14" or productName="WI17" or productName="WI20" or productName="WI21" or productName="WI21_Health" or productName="WI23" or productName="WI24" or productName="WI26" or productName="WI30" or productName="WI31" or productName="WI33" or productName="WI34" or productName="X001" or productName="X002" or productName="X003" or productName="X004" or productName="X005" or productName="X008" or productName="Y001" or productName="Y007" or productName="Y009" or productName="Y010" or productName="Y011" or productName="Y011H" or productName="Y020" or productName="Y020N" or productName="Z008" or productName="ZI001")]')=1
      INNER JOIN CENTER_CTR CTR ON CTR.ID_CTR=CTG.ID_CTR_CTG
        INNER JOIN MODEL_MDL MDL ON  MDL.ID_MDL=CTR.ID_MDL_CTR

  • How can I convert a string to a seperated characters?

    How can I convert a string to a separated characters without using array?
    such as: input = String "word"
    output =
    w
    o
    r
    d
    Thanks

    A string is stored internally in individual characters.
    The String class has a method 'charAt(int index)' which returns the character at that index so using a for loop..
    String s = "word";
    for(int counter=0; counter < s.length(); counter++)
    System.out.println(s.charAt(counter));
    HTH

  • REG: Split data on CRLF and Length of 10 characters

    Dear All,
    Oracle Database 11g R2 11.2.0.1 SE1
    Consider the below table which has 3 rows  
    ADDRESS
    aaaaaaaaaaaaaaaaaaaaaaaaaCRLFbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbCRLFcccccccccccccccCRLFddddd
    eeeeCRLFffffffffffffgggggggghCRLF
    iiCRLFjjjjjjjjjjkkkCRLF
    I need to split the string based on the below conditions
    Condition 1: Split string up-to CRLF.
    Condition 2: If length of the split string is greater than 10, then split that string by length of 10 characters.
    The length of a data is not fixed.
      RESULT:-
    ADDRESS
    aaaaaaaaaa
    aaaaaaaaaa
    aaaaaCRLF
    bbbbbbbbbb
    bbbbbbbbbb
    bbbbbbbbbb
    bbCRLF
    cccccccccc
    cccccCRLF
    ddddd
    eeeeCRLF
    ffffffffff
    ffgggggggg
    hCRLF
    iiCRLF
    jjjjjjjjjj
    kkkCRLF

    It can be done the obvious way, write your own PL/SQL function/procedure/package with cursor looping through your table, combining instr and substr with necessary conditions, and chopping your string down until it becomes empty, inserting the results into a separate table. If you need to do that in a single query or if you have trouble writing that code, you should go to SQL community - this forum is for SQLDeveloper tool related problems only.

  • Can the encrypted string contain only alphabets?

    Hi friends,
    I have problem with the encryption. I am using Des .
    I want to get the encrypted string which contains only alphabets ( no digits or no special characters).
    Help appreciated.
    Thanks.

    Within the Java Cryptographic Extension (JCE), encryption works on bytes and generates bytes. You can convert any arbitrary String to bytes using one of the String.getBytes() methods (preferably the one where you define the encoding to use). The way you restrict what the plane text String contains is up to you.
    The JCE produces secure encryption based on well tested algorithms.
    The tone of your question implies that all you want to do is have a simple substitution cipher. The is very VERY VERY insecure and can be broken by a 2 year old. Use the JCE.

  • Block (control) String length

    I want to Block the String length, like when ask to input student name but only allow user to input the name with maximum is 10 characters only, anyone can show me ?
    thanks alot

    Like i get Name and Mark from TextField and Print it out in Text Area
    I want to set the maximum character of name is 15 characters, so I use IF to control it
    but when it print out have some problems:
    tarea.append(name+ "\t");
    tarea.append(mark + "\t"); ===>name, and mark inside array
    ===
    so when it appear inside the TextArea like this :
    Name Mark
    Jimmy Lee Kok 98
    Jack 96
    Can i align the mark appears ?

Maybe you are looking for

  • Can a nook be used with os7

    Can a Nook be used with Apple products?  I don't want network or virus problems.

  • "Unable to update, log in with account that purchased app"

    Hi I get this error: "Unable to update, log in with account that purchased app" more or less, when trying to update apps on my other macbook pro. I *am* logged in with the account that purchased the apps; I ONLY purchase apps from apple's app store (

  • What is the default time settings in Process chains

    Hi, What is the default time settings in Process chains. How to set time settings for daily,weekly,monthly loads in Process chains. What is the time settings that we have to take care when creating meta chains. Thanks, Madhu.

  • Oracle FA FASRSVED.rdf report need to customized ...FABAL.pll

    Hi there I have to customized the report FASRSVED, I have downloaded the file and FABAL.pll. When I open the rdf into the Oracle Report I see the FA_BALANCES_REPORT_GT table , and If I go look data in sql I don't see any records. It looks like that t

  • How do I install filters into PSCC 2014?

    How do I install my filters from PS6 into PSCC 2014?  I know you can't just drag and drop them.  That caused all kinds of problems with PSCC.  I would like to do PSCC 2014 the right way to avoid problems.  The filters are from many different develope