how to use openssl random key in bash script?Using key file as password with OpenSSLHow to generate just a...

Jumping frame contents with beamer and pgfplots

What is the best way for a skeleton to impersonate human without using magic?

Is there anything special about -1 (0xFFFFFFFF) regarding ADC?

Can a tourist shoot a gun in the USA?

Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?

In books, how many dragons are there in present time?

Wireless headphones interfere with Wi-Fi signal on laptop

Why does lemon juice reduce the "fish" odor of sea food — specifically fish?

Can someone explain homicide-related death rates?

When a land becomes a creature, is it untapped?

Rounding a number extracted by jq to limit the decimal points

51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?

What information do scammers need to withdraw money from an account?

CPLD based Pierce oscillator

Effects of ~10atm pressure on engine design

If the square of a time series is stationary, is the original time series stationary?

How exactly does artificial gravity work?

What makes "quality" analog AV cables better than cheap cables?

Magento 2: How to get type columns of table in sql?

Automatically anti-predictably assemble an alliterative aria

Why does the headset man not get on the tractor?

What was the significance of Varys' little girl?

On what legal basis did the UK remove the 'European Union' from its passport?

Why was Endgame Thanos so different than Infinity War Thanos?



how to use openssl random key in bash script?


Using key file as password with OpenSSLHow to generate just a key with opensslOpenSSL - how to encrypt files with AES keyPipe openssl input to bash script readConverting SSH2 RSA Private Key to .pem using opensslopenSSL Key and CertificateHow to find which key exactly `dh key too small` OpenSSL error is about?DROP USER IF EXISTS syntax error in MySQL CLIHow do you use the AES key wrap cipher with the OpenSSL command line utility?openssl: Define private key / keyform / engine in configuration file






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















Below is my sample code:



KEY_FILE=/tmp/key.txt
KEY=$(openssl rand 16)
echo $KEY > $KEY_FILE
ID=2345
source .mysqlCredentials.txt
MySqlCommand="mysql -h $IP -u $UserName -p$Password $DBName -e"
$MySqlCommand "INSERT INTO some_table ( ID , ssl_key ) VALUES ("$ID", "$KEY") ;"


the error I get is :



+ mysql -h X.X.X.X -u root -ppassword database -e 'INSERT INTO  some_table ( ID , ssl_key ) VALUES ("2345", "ïëC;+¹"ë'''J£èMÑ") ;'
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ë'J£èMÑ")' at line 1


Here in the generated key, I'm getting single quotes, backticks, double quotes, and spaces ... etc...



how can I overcome this error?










share|improve this question





























    0















    Below is my sample code:



    KEY_FILE=/tmp/key.txt
    KEY=$(openssl rand 16)
    echo $KEY > $KEY_FILE
    ID=2345
    source .mysqlCredentials.txt
    MySqlCommand="mysql -h $IP -u $UserName -p$Password $DBName -e"
    $MySqlCommand "INSERT INTO some_table ( ID , ssl_key ) VALUES ("$ID", "$KEY") ;"


    the error I get is :



    + mysql -h X.X.X.X -u root -ppassword database -e 'INSERT INTO  some_table ( ID , ssl_key ) VALUES ("2345", "ïëC;+¹"ë'''J£èMÑ") ;'
    ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ë'J£èMÑ")' at line 1


    Here in the generated key, I'm getting single quotes, backticks, double quotes, and spaces ... etc...



    how can I overcome this error?










    share|improve this question

























      0












      0








      0








      Below is my sample code:



      KEY_FILE=/tmp/key.txt
      KEY=$(openssl rand 16)
      echo $KEY > $KEY_FILE
      ID=2345
      source .mysqlCredentials.txt
      MySqlCommand="mysql -h $IP -u $UserName -p$Password $DBName -e"
      $MySqlCommand "INSERT INTO some_table ( ID , ssl_key ) VALUES ("$ID", "$KEY") ;"


      the error I get is :



      + mysql -h X.X.X.X -u root -ppassword database -e 'INSERT INTO  some_table ( ID , ssl_key ) VALUES ("2345", "ïëC;+¹"ë'''J£èMÑ") ;'
      ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ë'J£èMÑ")' at line 1


      Here in the generated key, I'm getting single quotes, backticks, double quotes, and spaces ... etc...



      how can I overcome this error?










      share|improve this question














      Below is my sample code:



      KEY_FILE=/tmp/key.txt
      KEY=$(openssl rand 16)
      echo $KEY > $KEY_FILE
      ID=2345
      source .mysqlCredentials.txt
      MySqlCommand="mysql -h $IP -u $UserName -p$Password $DBName -e"
      $MySqlCommand "INSERT INTO some_table ( ID , ssl_key ) VALUES ("$ID", "$KEY") ;"


      the error I get is :



      + mysql -h X.X.X.X -u root -ppassword database -e 'INSERT INTO  some_table ( ID , ssl_key ) VALUES ("2345", "ïëC;+¹"ë'''J£èMÑ") ;'
      ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ë'J£èMÑ")' at line 1


      Here in the generated key, I'm getting single quotes, backticks, double quotes, and spaces ... etc...



      how can I overcome this error?







      bash openssl






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      msp9011msp9011

      4,98844168




      4,98844168






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Why don't you try base64 encoding the rand string? Like so:
          openssl rand -base64 16
          That is much easier to handle.






          share|improve this answer
























          • no... requirement is strictly to use AES

            – msp9011
            30 mins ago












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f518617%2fhow-to-use-openssl-random-key-in-bash-script%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Why don't you try base64 encoding the rand string? Like so:
          openssl rand -base64 16
          That is much easier to handle.






          share|improve this answer
























          • no... requirement is strictly to use AES

            – msp9011
            30 mins ago
















          0














          Why don't you try base64 encoding the rand string? Like so:
          openssl rand -base64 16
          That is much easier to handle.






          share|improve this answer
























          • no... requirement is strictly to use AES

            – msp9011
            30 mins ago














          0












          0








          0







          Why don't you try base64 encoding the rand string? Like so:
          openssl rand -base64 16
          That is much easier to handle.






          share|improve this answer













          Why don't you try base64 encoding the rand string? Like so:
          openssl rand -base64 16
          That is much easier to handle.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 32 mins ago









          EdwardEdward

          17116




          17116













          • no... requirement is strictly to use AES

            – msp9011
            30 mins ago



















          • no... requirement is strictly to use AES

            – msp9011
            30 mins ago

















          no... requirement is strictly to use AES

          – msp9011
          30 mins ago





          no... requirement is strictly to use AES

          – msp9011
          30 mins ago


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f518617%2fhow-to-use-openssl-random-key-in-bash-script%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...