• Home
  • About Us
  • Contact Us
  • DMCA
  • Sitemap
  • Privacy Policy
Tuesday, May 30, 2023
Insta Citizen
No Result
View All Result
  • Home
  • Technology
  • Computers
  • Gadgets
  • Software
  • Solar Energy
  • Artificial Intelligence
  • Home
  • Technology
  • Computers
  • Gadgets
  • Software
  • Solar Energy
  • Artificial Intelligence
No Result
View All Result
Insta Citizen
No Result
View All Result
Home Artificial Intelligence

Checksums and knowledge integrity in SAS applications

Insta Citizen by Insta Citizen
October 6, 2022
in Artificial Intelligence
0
Checksums and knowledge integrity in SAS applications
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter



Have you ever ever typed your bank card into a web-based order kind and been informed that you simply entered the flawed quantity? Maybe you puzzled, “How do they know that the numbers I typed don’t make a sound bank card quantity?”
The reply is that bank card numbers and different account numbers incorporate a easy rule that protects in opposition to many typographical errors.
Usually, a rule that validates a block of information known as a checksum.
The checksum that’s utilized by bank cards is computed by utilizing
the Luhn algorithm or the “mod 10” algorithm.
Chris Hemedinger wrote a weblog put up that exhibits find out how to implement the Luhn checksum algorithm in SAS.


You can even use checksum strategies to make sure that info
or knowledge will not be modified after it’s created.
I lately wanted to make sure that some knowledge was not being corrupted because it was handed alongside a sophisticated SAS/IML program. I used to be ready to make use of the SHA256 operate in SAS to create a checksum for the info. Chris Hemedinger has a weblog put up that describes the SHA256 operate and find out how to name it from the SAS DATA step to make sure the info integrity of character knowledge. Though he would not say it, you should utilize the SHA256 operate on numerical knowledge by making use of a format to the worth (for instance, by utilizing the PUTN operate in SAS). The format will decide the worth of the checksum.


This text exhibits find out how to use the SHA256 operate to create a checksum for character and numerical knowledge. For SAS/IML programmers, I additionally present find out how to
use a checksum to make sure that objects in a SAS/IML listing haven’t modified because the listing was created.

Hashing character values


You need to use any hash operate to create a checksum. SAS helps a big number of hash features. This text makes use of the SHA256 operate, however you should utilize a distinct operate for those who favor.


The next instance illustrates how you should utilize a hash operate for an array of character values. Within the SAS/IML language, the ROWVEC operate takes a matrix of enter values and converts them right into a one-dimensional row vector. The ROWCATC operate takes a personality matrix and concatenates the values throughout columns, eradicating all areas.
Thus, the SAS/IML expression rowcatc(rowvec(m)) returns a string that concatenates the weather in m.
You possibly can carry out an analogous operation within the SAS DATA step by utilizing the CATS operate.

/* a easy checksum: SHA256 utilized to knowledge strings */
proc iml;
ID = {"Andrew", "Sofya", "Shing", "Maryam", "Terence"};
 
str1 = rowcatc(rowvec(ID)); 
hash = sha256(str1);
print str1, hash[F=$hex64.];


This system takes the names of 5 individuals, concatenates them collectively into a protracted string, after which applies the SHA256 hash operate. The output is a fixed-length string. For the SHA256 operate, the output string incorporates 256 bits. Since every hexadecimal digit can signify 4 bits of knowledge, you’ll be able to show this 256-bit worth by utilizing a 64-character hexadecimal string. This is among the benefits of utilizing a hash operate: whatever the size of the unique string, the output is a string of a recognized size.

Hashing numerical values


If you wish to hash an array of character values, you should utilize the PUTN operate in SAS to use a format, which converts the array of numbers right into a string. This text makes use of the BEST12. format. For those who use a distinct format, you’re going to get a distinct string and a distinct hash worth.


In SAS 9.4, character strings are restricted to 32,767 characters. (In SAS Viya, you should utilize the VARCHAR sort to retailer strings of any size.) For those who allocate 12 characters to every quantity, you’ll be able to encode at most 32767/12 = 2730 numbers right into a single string. There are methods to get round this, however for simplicity, if an array incorporates greater than 100 values, I’ll use solely the primary 100 values to create the hash worth. That is applied within the following SAS/IML user-defined operate, which takes a matrix of numbers as enter and returns a protracted string illustration of the numbers:

begin NumToStr(m, maxN=100);
   if nrow(m)*ncol(m) < maxN then 
      s = putn(m, "BEST12.");          /* apply format to all values */
   else
      s = putn(m[1:maxN], "BEST12.");  /* apply format to first 100 values */
   return( rowcatc(rowvec(s)) );       /* concatenate values into one string */
end;
 
Top = {175, 143, 165, 157, 161};      /* cm */
Weight = {50, 38.5, 44, 46.5, 47};       /* kg */
corr = 0.8805;
 
str2 = NumToStr(Top);
str3 = NumToStr(Weight);
str4 = NumToStr(corr);
print str3;


The operate converts an array of numbers right into a string of formatted values.
The operate is examined by utilizing two arrays and one scalar worth.
One of many strings is proven. You possibly can see that the formatted Weight values (which embrace decimal factors) are concatenated right into a string.

Making a checksum


The earlier sections created 4 strings: str1, str2, str3, and str4.
Discover that the correlation worth (0.8972) depends on the Top and Weight knowledge values. If the values in these arrays had been to alter (both by chance or deliberately), it will be helpful to know that the correlation worth is now not legitimate.
One method to discover out if any info has modified is to create a checksum for the unique info and periodically examine the unique checksum to the checksum for the present state of the knowledge.
The next statements compute the checksum for the unique knowledge by concatenating the strings for the ID, Top, Weight, and Corr variables and computing the SHA256 worth of the consequence:

s = cats(str1, str2, str3, str4);
verify = sha256(s);
print verify[F=$hex64.];


The output is a checksum. For those who modify any of the numbers or strings in these arrays, then (with excessive likelihood) the brand new checksum won’t match the unique checksum. For instance, the next statements compute the checksum for the correlation equal to “0.89”. The brand new checksum is completely different from the unique checksum, which tells you that a number of knowledge values have modified.

/* What if the numbers or order of numbers change? */
s = cats(str1, str2, str3, "0.89");
check1 = sha256(s);
print check1[F=$hex64.];

A checksum for a SAS/IML listing


This part exhibits one method to automate the computations within the earlier sections.
Within the SAS/IML Language, it’s typically handy to use an inventory to pack associated info right into a single object that you may go to features.
This part exhibits find out how to compute the checksum for an inventory of arbitrary objects.


This system defines the next features:

  • The CharToStr operate concatenates as much as 100 components in a personality matrix. The result’s a single string.
  • The NumToStr operate applies the BEST12. format to as much as 100 components in a numeric matrix. These formatted values are concatenated collectively to kind a single string.
  • The GetChecksum operate iterates over the objects in an inventory. If an merchandise is a personality matrix, name the CharToStr operate. If the merchandise is a numeric matrix, name the NumToStr operate. For simplicity, different objects are skipped on this implementation. The strings for every merchandise are concatenated collectively. The SHA256 operate creates a hash worth for the concatenated strings.


This course of is demonstrated by utilizing the identical knowledge as within the earlier sections:

proc iml;
begin CharToStr(s, maxN=100);
   if nrow(s)*ncol(s) < maxN then 
      return( rowcatc(rowvec(s)) );         /* concatenate all values */
   else
      return( rowcatc(rowvec(s[1:maxN])) ); /* concatenate 100 values */
end;
 
begin NumToStr(m, maxN=100);
   if nrow(m)*ncol(m) < maxN then 
      s = putn(m, "BEST12.");          /* apply format to all values */
   else
      s = putn(m[1:maxN], "BEST12.");  /* apply format to first 100 values */
   return( CharToStr(s) );             /* concatenate values into one string */
end;
 
/* get hash of the numerical and character components of an inventory*/
begin GetChecksum(L);
   allStr = "";
   do i = 1 to ListLen(L);
      m = L$i;
      if sort(m)='N' then 
         str = NumToStr(m);
      else if sort(m)='C' then
         str = CharToStr(m);
      else str = "";         /* you might deal with different varieties right here */
      allStr = cats(allStr, str);
   finish;
   checksum = sha256(allStr);
   return checksum;
end;
 
ID = {"Andrew", "Sofya", "Shing", "Maryam", "Terence"};
Top = {175, 143, 165, 157, 161};      /* cm */
Weight = {50, 38.5, 44, 46.5, 47};       /* kg */
corr = 0.8805;
 
L = [ID, Height, Weight, corr];   /* listing with 4 objects */
verify = GetChecksum(L);
print verify[F=$hex64.];


The hash worth on this program is equivalent to the hash worth for the unique knowledge. That’s as a result of the objects had been packed into the listing in the identical order.


This course of was motivated by a real-life downside. I used to be writing a sophisticated program that pre-computes sure statistics after which calls a collection of features.
I needed to make sure that the objects within the listing weren’t modified because the listing was handed from operate to operate. A technique to do this is to compute the checksum of the unique objects within the listing
and examine it to the checksum on the finish of this system.

Abstract


This text discusses find out how to use a hash operate to compute a checksum to make sure knowledge integrity.
The article makes use of the SHA256 hash operate, however SAS helps different hash features.
A hash operate takes an arbitrary string as enter and returns a fixed-length string, referred to as the hash worth. With excessive likelihood, the hash worth “identifies” the info: for those who change the info, you’re more likely to acquire a distinct hash worth.
You need to use this truth to compute a checksum for the unique knowledge
and examine it to the checksum for the info at a later time. If the checksum has modified, the info have been corrupted.



Source_link

READ ALSO

What occurs when robots lie? — ScienceDaily

NerfDiff: Single-image View Synthesis with NeRF-guided Distillation from 3D-aware Diffusion

Related Posts

How deep-network fashions take probably harmful ‘shortcuts’ in fixing complicated recognition duties — ScienceDaily
Artificial Intelligence

What occurs when robots lie? — ScienceDaily

May 29, 2023
Neural Transducer Coaching: Diminished Reminiscence Consumption with Pattern-wise Computation
Artificial Intelligence

NerfDiff: Single-image View Synthesis with NeRF-guided Distillation from 3D-aware Diffusion

May 29, 2023
Expertise Innovation Institute Open-Sourced Falcon LLMs: A New AI Mannequin That Makes use of Solely 75 % of GPT-3’s Coaching Compute, 40 % of Chinchilla’s, and 80 % of PaLM-62B’s
Artificial Intelligence

Expertise Innovation Institute Open-Sourced Falcon LLMs: A New AI Mannequin That Makes use of Solely 75 % of GPT-3’s Coaching Compute, 40 % of Chinchilla’s, and 80 % of PaLM-62B’s

May 29, 2023
Probabilistic AI that is aware of how nicely it’s working | MIT Information
Artificial Intelligence

Probabilistic AI that is aware of how nicely it’s working | MIT Information

May 29, 2023
Construct a robust query answering bot with Amazon SageMaker, Amazon OpenSearch Service, Streamlit, and LangChain
Artificial Intelligence

Construct a robust query answering bot with Amazon SageMaker, Amazon OpenSearch Service, Streamlit, and LangChain

May 28, 2023
De la creatividad a la innovación
Artificial Intelligence

De la creatividad a la innovación

May 28, 2023
Next Post
Perforce updates Helix ALM with enhanced automated testing assist

Perforce updates Helix ALM with enhanced automated testing assist

POPULAR NEWS

AMD Zen 4 Ryzen 7000 Specs, Launch Date, Benchmarks, Value Listings

October 1, 2022
Benks Infinity Professional Magnetic iPad Stand overview

Benks Infinity Professional Magnetic iPad Stand overview

December 20, 2022
Migrate from Magento 1 to Magento 2 for Improved Efficiency

Migrate from Magento 1 to Magento 2 for Improved Efficiency

February 6, 2023
Only5mins! – Europe’s hottest warmth pump markets – pv journal Worldwide

Only5mins! – Europe’s hottest warmth pump markets – pv journal Worldwide

February 10, 2023
Magento IOS App Builder – Webkul Weblog

Magento IOS App Builder – Webkul Weblog

September 29, 2022

EDITOR'S PICK

Congrats to our 2022 consumer recognition award winners

Congrats to our 2022 consumer recognition award winners

September 29, 2022
Pakistan accredited 280 MW of photo voltaic in 2021-22 – pv journal Worldwide

Pakistan accredited 280 MW of photo voltaic in 2021-22 – pv journal Worldwide

October 13, 2022
Listed here are the three finest Inventive Cloud applied sciences showcased at Adobe MAX Sneaks 2022

Listed here are the three finest Inventive Cloud applied sciences showcased at Adobe MAX Sneaks 2022

October 21, 2022
Q-Pixel introduces 5,000 PPI full-color UHD microLED show

Q-Pixel introduces 5,000 PPI full-color UHD microLED show

May 20, 2023

Insta Citizen

Welcome to Insta Citizen The goal of Insta Citizen is to give you the absolute best news sources for any topic! Our topics are carefully curated and constantly updated as we know the web moves fast so we try to as well.

Categories

  • Artificial Intelligence
  • Computers
  • Gadgets
  • Software
  • Solar Energy
  • Technology

Recent Posts

  • X-Sense SC07-W Wi-fi Interlinked Mixture Smoke and Carbon Monoxide Alarm assessment – Please shield your own home and household!
  • NYC lawyer in huge hassle after utilizing ChatGPT to write down authorized temporary
  • Benefits and Disadvantages of OOP in Java
  • Intel Discloses New Particulars On Meteor Lake VPU Block, Lays Out Imaginative and prescient For Consumer AI
  • Home
  • About Us
  • Contact Us
  • DMCA
  • Sitemap
  • Privacy Policy

Copyright © 2022 Instacitizen.com | All Rights Reserved.

No Result
View All Result
  • Home
  • Technology
  • Computers
  • Gadgets
  • Software
  • Solar Energy
  • Artificial Intelligence

Copyright © 2022 Instacitizen.com | All Rights Reserved.

What Are Cookies
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT